cgccglibc

Check glibc version for a particular gcc compiler


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 gcc 4.4.4, because /lib/libc.so.6 shows the glibc used by gcc 4.1.2, since it is the default compiler.


Solution

  • 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.