查看当前系统的glibc版本
有時我們經常需要查看當前系統的glibc版本,可以這樣查看:
/lib/libc.so.6
有時:/lib/x86-64-linux/libc.so.6
把這個文件當命令執行一下
為什么這個庫可以直接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的關系?
glibc是gnu發布的libc庫,也即c運行庫。glibc是linux系統中最底層的api(應用程序開發接口),幾乎其他任何的運行庫都會依賴于glibc。glibc除了封裝linux操作系統所提供的系統服務外,它本身也提供了許多其它一些必要功能服務的實現,主要的如下:
(1) string,字符串處理
(2) signal, 信號處理
(3) dlfcn, 管理共享庫的動態加載
(4) direct,文件目錄操作
(5) elf, 共享庫的動態加載器,也即interpreter
(6) iconv,不同字符集的編碼轉換
(7) inet, socket接口的實現
(8) intl, 國際化,也即gettext的實現
(9) io
(10) linuxthreads
(11) locale, 本地化
(12) login, 虛擬終端設備的管理,及系統的安全訪問
(13) malloc,動態內存的分配和管理
(14) nis
(15) stdlib, 其他基本功能
gcc是編譯器,基本上Linux下所有的程序(包括內核)都是gcc編譯的,libc當然也是。
gcc和libc是互相依賴的兩個軟件,它們合作的方式類似Linux系統的“自舉”。先在一個可以運行的帶有老libc和gcc的系統上,用老gcc編譯出一個新版本的gcc+老libc,再用這個新gcc編譯出一個新gcc+新libc,再用這套東西編譯整個新系統。
?
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
轉自:https://my.oschina.net/acmfly/blog/77211
總結
以上是生活随笔為你收集整理的查看当前系统的glibc版本的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: nginx1.11.*版本追加安装sti
- 下一篇: 微服务架构--链路追踪(Nginx篇)