Check glibc version for a particular gcc compiler

后端 未结 8 1205
既然无缘
既然无缘 2020-11-29 19:13

I have two gcc compilers installed on my system, one is gcc 4.1.2 (default) and the other is gcc 4.4.4. How can I check the libc version used by

8条回答
  •  轻奢々
    轻奢々 (楼主)
    2020-11-29 19:30

    Use -print-file-name gcc option:

    $ gcc -print-file-name=libc.so
    /usr/lib/gcc/x86_64-redhat-linux/4.5.1/../../../../lib64/libc.so
    

    That gives the path. Now:

    $ file /usr/lib/gcc/x86_64-redhat-linux/4.5.1/../../../../lib64/libc.so
    /usr/lib/gcc/x86_64-redhat-linux/4.5.1/../../../../lib64/libc.so: ASCII C program text
    
    $ cat /usr/lib/gcc/x86_64-redhat-linux/4.5.1/../../../../lib64/libc.so
    /* GNU ld script
       Use the shared library, but some functions are only in
       the static library, so try that secondarily.  */
    OUTPUT_FORMAT(elf64-x86-64)
    GROUP ( /lib64/libc.so.6 /usr/lib64/libc_nonshared.a  AS_NEEDED ( /lib64/ld-linux-x86-64.so.2 ) )
    

    Looks like a linker script. libc is special on Linux in that it can be executed:

    $ /lib64/libc.so.6
    GNU C Library stable release version 2.13, by Roland McGrath et al.
    Copyright (C) 2011 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 4.5.1 20100924 (Red Hat 4.5.1-4).
    Compiled on a Linux 2.6.35 system on 2011-08-05.
    Available extensions:
        Support for some architectures added on, not maintained in glibc core.
        The C stubs add-on version 2.1.2.
        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
        RT using linux kernel aio
    libc ABIs: UNIQUE IFUNC
    For bug reporting instructions, please see:
    .
    

提交回复
热议问题