Check glibc version for a particular gcc compiler
Write a test program (name it for example glibc-version.c
):
#include <stdio.h>#include <stdlib.h>#include <gnu/libc-version.h>int main(int argc, char *argv[]) { printf("GNU libc version: %s\n", gnu_get_libc_version()); exit(EXIT_SUCCESS);}
and compile it with the gcc-4.4 compiler:
gcc-4.4 glibc-version.c -o glibc-version
When you execute ./glibc-version
the used glibc version is shown.
even easier
use ldd --version
This should return the glibc version being used i.e.
$ ldd --versionldd (GNU libc) 2.17Copyright (C) 2012 Free Software Foundation, Inc.This is free software; see the source for copying conditions. There is NO
...
which is the same result as running my libc library
$ /lib/libc.so.6 GNU C Library (GNU libc) stable release version 2.17, by Roland McGrath et al.Copyright (C) 2012 Free Software Foundation, Inc.This is free software; see the source for copying conditions.
...
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.6GNU 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 APARTICULAR 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 aiolibc ABIs: UNIQUE IFUNCFor bug reporting instructions, please see:<http://www.gnu.org/software/libc/bugs.html>.