How to find which libc version app links against?

When building an application using g++, I am not explicitly passing the libc library as a library to link against in the same way you would do it for other libraries (like passing -lpthread for example).

I know that libc has the libc.so.6 so name, but I am aware that this is not actually a library but something like a pointer to another version of libc (such as libc-2.15.so).

If I had multiple versions of libc on my computer, how can I tell which one actually gets used using libc.so.6?

1 Answer

ldd should be the tool of your choice. That gives you the shared library actually linked.

confus@confusion:~/misc/test$ ldd -r -v testendian linux-vdso.so.1 => (0x00007fffbcfff000) libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f1a5a4c5000) /lib64/ld-linux-x86-64.so.2 (0x00007f1a5a8a5000) Version information: ./testendian: libc.so.6 (GLIBC_2.2.5) => /lib/x86_64-linux-gnu/libc.so.6 /lib/x86_64-linux-gnu/libc.so.6: ld-linux-x86-64.so.2 (GLIBC_2.3) => /lib64/ld-linux-x86-64.so.2 ld-linux-x86-64.so.2 (GLIBC_PRIVATE) => /lib64/ld-linux-x86-64.so.2

In case of the libc you can simply run the .so file and will be told the library version.

confus@confusion:~/misc/test$ /lib/x86_64-linux-gnu/libc.so.6
GNU C Library (Ubuntu EGLIBC 2.15-0ubuntu10) stable release version 2.15, by Roland McGrath et al.
3

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

You Might Also Like