《GNU C : 获取版本号》

GUN C 语言函数库是 Linux 上最常用的库 (glibc) http://www.gnu.org/

应用程序可以通过测试常量和调用库函数两种方法,来确定系统安装的glibc版本,从2.0开始,glibc提供两个常量

__GLIBC__ 和 __GLIBC_MINOR__  

 

一、程序获取glibc 版本号

// gunc_lib_version.c 
#include<stdio.h>                                                                
#include<gnu/libc-version.h>

int main(void)
{
   char * str_gnu_ver = gnu_get_libc_version();

   printf("gnu lib version : %s \n",str_gnu_ver);
   printf("__GLIBC__ =  %d \n",__GLIBC__);
   printf("__GLIBC_MINOR__  = %d \n",__GLIBC_MINOR__);

   return 0 ;
}
~    

编译运行: gcc gunc_lib_version.c  -o  gunc_lib_version

yexiang@ubuntu:<Linux_work>$ ./gunc_lib_version 
gnu lib version : 2.23 
__GLIBC__ =  2 
__GLIBC_MINOR__  = 23 

二、查看程序连接的glibc库

yexiang@ubuntu:<Linux_work>$ ldd gunc_lib_version | grep libc               
        libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f0d165ac000)


yexiang@ubuntu:<Linux_work>$ /lib/x86_64-linux-gnu/libc.so.6
GNU C Library (Ubuntu GLIBC 2.23-0ubuntu11) stable release version 2.23, by Roland McGrath et al.
Copyright (C) 2016 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.
Compiled by GNU CC version 5.4.0 20160609.
Available extensions:
        crypt add-on version 2.1 by Michael Glad and others
        GNU Libidn by Simon Josefsson
        Native POSIX Threads Library by Ulrich Drepper et al
        BIND-8.2.3-T5B
libc ABIs: UNIQUE IFUNC
For bug reporting instructions, please see:
<https://bugs.launchpad.net/ubuntu/+source/glibc/+bugs>.

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

HarkerYX

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值