glibc/libc/blib區別

來源:互聯網
上載者:User

標籤:des   blog   http   io   os   使用   ar   strong   for   

轉自:http://blog.csdn.net/yasi_xi/article/details/9899599

【glibc 和 libc】 

glibc 和 libc 都是 Linux 下的 C 函數庫。 
libc 是 Linux 下的 ANSI C 函數庫;glibc 是 Linux 下的 GUN C 函數庫。 

ANSI C 和 GNU C 有什麼區別呢? 

       ANSI C 函數庫是基本的 C 語言函數庫,包含了 C 語言最基本的庫函數。這個庫可以根據標頭檔劃分為 15 個部分,其中包括: 

  1. <ctype.h>:包含用來測試某個特徵字元的函數的函數原型,以及用來轉換大小寫字母的函數原型;
  2. <errno.h>:定義用來報告錯誤條件的宏;
  3. <float.h>:包含系統的浮點數大小限制;
  4. <math.h>:包含數學庫函數的函數原型;
  5. <stddef.h>:包含執行某些計算 C 所用的常見的函數定義;
  6. <stdio.h>:包含標準輸入輸出庫函數的函數原型,以及他們所用的資訊;
  7. <stdlib.h>:包含數字轉換到文本,以及文本轉換到數位函數原型,還有記憶體配置、隨機數字以及其他實用函數的函數原型;
  8. <string.h>:包含字串處理函數的函數原型;
  9. <time.h>:包含時間和日期操作的函數原型和類型;
  10. <stdarg.h>:包含函數原型和宏,用於處理未知數值和類型的函數的參數列表;
  11. <signal.h>:包含函數原型和宏,用於處理常式執行期間可能出現的各種條件;
  12. <setjmp.h>:包含可以繞過一般函數調用並返回序列的函數的原型,即非局部跳轉;
  13. <locale.h>:包含函數原型和其他資訊,使程式可以針對所啟動並執行地區進行修改。
  14. 地區的表示方法可以使電腦系統處理不同的資料表達約定,如全世界的日期、時間、美元數和大數字;
  15. <assert.h>:包含宏和資訊,用於進行診斷,協助程式調試。

上述庫函數在其各種支援 C 語言的 IDE 中都是有的。 

       GNU C 函數庫是一種類似於第三方外掛程式的東西。由於 Linux 是用 C 語言寫的,所以 Linux 的一些操作是用 C 語言實現的,因此,GUN 組織開發了一個 C 語言的庫 以便讓我們更好的利用 C 語言開發基於 Linux 作業系統的程式。不過現在的不同的 Linux 的發行版本對這兩個函數庫有不同的處理方法,有的可能已經整合在同一個庫裡了。 

 

glibc是linux下面c標準庫的實現,即GNU C Library。glibc本身是GNU旗下的C標準庫,後來逐漸成為了Linux的標準c庫,而Linux下原來的標準c庫Linux libc逐漸不再被維護。Linux下面的標準c庫不僅有這一個,如uclibc、klibc,以及上面被提到的Linux libc,但是glibc無疑是用得最多的。glibc在/lib目錄下的.so檔案為libc.so.6。

 

查看當前系統的 glibc 版本的兩種方法: 
1.

01 [[email protected] ~]# /lib/libc.so.6
02 GNU C Library stable release version 2.5, by Roland McGrath et al.
03 Copyright (C) 2006 Free Software Foundation, Inc.
04 This is free software; see the source for copying conditions.
05 There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A
06 PARTICULAR PURPOSE.
07 Compiled by GNU CC version 4.1.2 20080704 (Red Hat 4.1.2-52).
08 Compiled on a Linux 2.6.9 system on 2013-01-08.
09 Available extensions:
10         The C stubs add-on version 2.1.2.
11         crypt add-on version 2.1 by Michael Glad and others
12         GNU Libidn by Simon Josefsson
13         GNU libio by Per Bothner
14         NIS(YP)/NIS+ NSS modules 0.19 by Thorsten Kukuk
15         Native POSIX Threads Library by Ulrich Drepper et al
16         BIND-8.2.3-T5B
17         RT using linux kernel aio
18 Thread-local storage support included.
19 For bug reporting instructions, please see:
20 <http://www.gnu.org/software/libc/bugs.html>.
21 [[email protected] ~]#

2. 

1 [[email protected] ~]# ldd  --version
2 ldd (GNU libc) 2.5
3 Copyright (C) 2006 Free Software Foundation, Inc.
4 This is free software; see the source for copying conditions.  There is NO
5 warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
6 Written by Roland McGrath and Ulrich Drepper.
7 [[email protected] ~]#



【glibc 和 glib】 

      錯誤觀點:glib 前面有個 "g" ,所以認為 glib 是 GNU 的東東;同時認為 glibc 是 glib 的一個子集。 

      其實,glib 和 glibc 基本上沒有太大聯絡,可能唯一的共同點就是,其都是 C 編程需要調用的庫而已。 
glib 是 Gtk+ 庫和 Gnome 的基礎。glib 可以在多個平台下使用,比如 Linux、Unix、Windows 等。glib 為許多標準的、常用的 C 語言結構提供了相應的替代物。 

glib是GTK+的基礎庫,它由基礎類型、對核心應用的支援、實用功能、資料類型和對象系統五個部分組成,可以在[http://www.gtk.org gtk網站]下載其原始碼。是一個綜合用途的實用的輕量級的C程式庫,它提供C語言的常用的資料結構的定義、相關的處理函數,有趣而實用的宏,可移植的封裝和一些運行時機能,如事件迴圈、線程、動態調用、對象系統等的API。GTK+是可移植的,當然glib也是可移植的,你可以在linux下,也可以在windows下使用它。使用gLib2.0(glib的2.0版本)編寫的應用程式,在編譯時間應該在編譯命令中加入pkg-config --cflags --libs glib-2.0,如:

gcc pkg-config --cflags --libs glib-2.0 hello.c -o hello

使用glib最有名的就是GNOME了。

 

【官方說明】

 

Glib

GLib is a general-purpose utility library, which provides many useful data types, macros, type conversions, string utilities, file utilities, a main loop abstraction, and so on. It works on many UNIX-like platforms, Windows, OS/2 and BeOS. GLib is released under the GNU Library General Public License (GNU LGPL).
The general policy of GLib is that all functions are invisibly threadsafe with the exception of data structure manipulation functions, where, if you have two threads manipulating the same data structure, they must use a lock to synchronize their operation.
GLib is the low-level core library that forms the basis for projects such as GTK+ and GNOME. It provides data structure handling for C, portability wrappers, and interfaces for such runtime functionality as an event loop, threads, dynamic loading, and an object system. 


Glibc 

Overview: 
Any Unix-like operating system needs a C library: the library which defines the ``system calls‘‘ and other basic facilities such as open, malloc, printf, exit... 
The GNU C Library is used as the C library in the GNU systems and most systems with the Linux kernel.
Project Goals:  
The GNU C Library is primarily designed to be a portable and high performance C library. It follows all relevant standards including ISO C11 and POSIX.1-2008. It is also internationalized and has one of the most complete internationalization interfaces known.
History: 
The history of Unix and various standards determine much of the interface of the C library. In general the GNU C Library supports the ISO C and POSIX standards. We also try to support the features of popular Unix variants (including BSD and System V) when those do not conflict with the standards. Different compatibility modes (selectable when you compile an application) allow the peaceful coexistence of compatibility support for different varieties of Unix. 


【其他說法】 

libc 實際上是一個泛指。凡是符合實現了 C 標準規定的內容,都是一種 libc 。
glibc 是 GNU 組織對 libc 的一種實現。它是 unix/linux 的根基之一。
微軟也有自己的 libc 實現,叫 msvcrt 。
嵌入式行業裡還常用 uClibc ,是一個迷你版的 libc 。

【yasi】

libc, glibc在一個層次,都是C的標準實現庫,是作業系統層級的基石之一。

glib是用C寫的一些utilities,即C的工具庫,和libc/glibc沒有關係。

glibc/libc/blib區別

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.