查看当前系统的glibc版本
有時我們經(jīng)常需要查看當(dāng)前系統(tǒng)的glibc版本,可以這樣查看:
/lib/libc.so.6
有時:/lib/x86-64-linux/libc.so.6
把這個文件當(dāng)命令執(zhí)行一下
為什么這個庫可以直接run呢?原來在libc的代碼中有一點小手腳:
Makerules:586:LDFLAGS-c.so += -e __libc_main csu/version.c:71:__libc_main(void) void __libc_main(void) {__libc_print_version();_exit(0); }或者:
因為ldd命令也是glibc提供的,所以也能查看
ldd --version
glibc是什么,以及與gcc的關(guān)系?
glibc是gnu發(fā)布的libc庫,也即c運行庫。glibc是linux系統(tǒng)中最底層的api(應(yīng)用程序開發(fā)接口),幾乎其他任何的運行庫都會依賴于glibc。glibc除了封裝linux操作系統(tǒng)所提供的系統(tǒng)服務(wù)外,它本身也提供了許多其它一些必要功能服務(wù)的實現(xiàn),主要的如下:
(1) string,字符串處理
(2) signal, 信號處理
(3) dlfcn, 管理共享庫的動態(tài)加載
(4) direct,文件目錄操作
(5) elf, 共享庫的動態(tài)加載器,也即interpreter
(6) iconv,不同字符集的編碼轉(zhuǎn)換
(7) inet, socket接口的實現(xiàn)
(8) intl, 國際化,也即gettext的實現(xiàn)
(9) io
(10) linuxthreads
(11) locale, 本地化
(12) login, 虛擬終端設(shè)備的管理,及系統(tǒng)的安全訪問
(13) malloc,動態(tài)內(nèi)存的分配和管理
(14) nis
(15) stdlib, 其他基本功能
gcc是編譯器,基本上Linux下所有的程序(包括內(nèi)核)都是gcc編譯的,libc當(dāng)然也是。
gcc和libc是互相依賴的兩個軟件,它們合作的方式類似Linux系統(tǒng)的“自舉”。先在一個可以運行的帶有老libc和gcc的系統(tǒng)上,用老gcc編譯出一個新版本的gcc+老libc,再用這個新gcc編譯出一個新gcc+新libc,再用這套東西編譯整個新系統(tǒng)。
?
glibc版本查看:
4.9. How can I find out which version of glibc I am using in the moment?
{UD} If you want to find out about the version from the command line simply run the libc binary.
This is probably not possible on all platforms but where it is simply locate the libc DSO and start it as an application.
On Linux like /lib/libc.so.6 This will produce all the information you need. What always will work is to use the API
glibc provides. Compile and run the following little program to get the version information:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#include <stdio.h> #include <gnu/libc-version.h> int main (void) { puts (gnu_get_libc_version ()); return 0; } ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
This interface can also obviously be used to perform tests at runtime if this should be necessary.
Just execute:
ldd --version
which comes with glibc package
轉(zhuǎn)自:https://my.oschina.net/acmfly/blog/77211
總結(jié)
以上是生活随笔為你收集整理的查看当前系统的glibc版本的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: nginx1.11.*版本追加安装sti
- 下一篇: 在windows上编译apr等相关动态库