linux系統編程:擷取glibc的版本號碼,linuxglibc

來源:互聯網
上載者:User

linux系統編程:擷取glibc的版本號碼,linuxglibc

我的環境是ubuntu16.04

glibc官網:http://www.gnu.org/software/libc/libc.html

方法一、一般來說,涉及到庫調用的程式,在連結時候都會連結到glibc,所以,可以用ldd命令來查看

ghostwu@ubuntu:~/c_program/linux_unix/chapter4$ ldd ./pwd | grep libc    libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f7c45491000)ghostwu@ubuntu:~/c_program/linux_unix/chapter4$ /lib/x86_64-linux-gnu/libc.so.6 GNU C Library (Ubuntu GLIBC 2.23-0ubuntu9) 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 APARTICULAR 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-T5Blibc ABIs: UNIQUE IFUNCFor bug reporting instructions, please see:<https://bugs.launchpad.net/ubuntu/+source/glibc/+bugs>.

這個就是我的電腦上glibc的路徑:/lib/x86_64-linux-gnu/libc.so.6

方法二:man -k glibc,可以找到一個系統函數gnu_get_libc_version,他可以用來擷取版本

ghostwu@ubuntu:~$ man -k libccracklib-check (8)   - Check passwords using libcrack2create-cracklib-dict (8) - Check passwords using libcrack2curl-config (1)      - Get information about a libcurl installationerror (3)            - glibc error reporting functionserror_at_line (3)    - glibc error reporting functionserror_message_count (3) - glibc error reporting functionserror_one_per_line (3) - glibc error reporting functionserror_print_progname (3) - glibc error reporting functionsglibc (7)            - overview of standard C libraries on Linuxgnu_get_libc_release (3) - get glibc version and releasegnu_get_libc_version (3) - get glibc version and releaselibc (7)             - overview of standard C libraries on Linuxghostwu@ubuntu:~$ man 3 gnu_get_libc_version 
/*================================================================*   Copyright (C) 2018 . All rights reserved.*   *   檔案名稱:check_glibc_version.c*   創 建 者:ghostwu(吳華)*   建立日期:2018年01月10日*   描    述:擷取GNU C庫(glibc)的版本號碼*================================================================*/#include <stdio.h>#include <gnu/libc-version.h>int main(int argc, char *argv[]){    printf( "glibc's version: %s\n", gnu_get_libc_version() );    return 0;}

方法三、getconf GNU_LIBC_VERSION

 

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.