Linux系统glibc库版本信息查看
cent7.9
# ldd --version
ldd (GNU libc) 2.17
Copyright (C) 2012 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
Written by Roland McGrath and Ulrich Drepper.
deepin 20.9
$ ldd --version
ldd (Debian GLIBC 2.28.21-1+deepin-1) 2.28
Copyright (C) 2018 自由软件基金会。
这是一个自由软件;请见源代码的授权条款。本软件不含任何没有担保;甚至不保证适销性
或者适合某些特殊目的。
由 Roland McGrath 和 Ulrich Drepper 编写。
----------------------
有时我们经常需要查看当前系统的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
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】凌霞软件回馈社区,博客园 & 1Panel & Halo 联合会员上线
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】博客园社区专享云产品让利特惠,阿里云新客6.5折上折
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 在鹅厂做java开发是什么体验
· 百万级群聊的设计实践
· WPF到Web的无缝过渡:英雄联盟客户端的OpenSilver迁移实战
· 永远不要相信用户的输入:从 SQL 注入攻防看输入验证的重要性
· 浏览器原生「磁吸」效果!Anchor Positioning 锚点定位神器解析
2018-09-25 mybatis中mapUnderscoreToCamelCase自动驼峰命名转换
2018-09-25 人体湿气重有哪些表现? 细数湿气重的危害
2017-09-25 如何更好的与人固执的人相处