Ask Ubuntu is a question and answer site for Ubuntu users and developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

When building an application using g++, I am not explicitly passing the libc library as a library to link to in the same way you would for other libraries (like passing -lpthread for example). I know that libc has the 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 My question is if I had multiple versions of libc on my computer, how can I tell which one actually gets linked to through the

share|improve this question
up vote 10 down vote accepted

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

confus@confusion:~/misc/test$ ldd -r -v testendian =>  (0x00007fffbcfff000) => /lib/x86_64-linux-gnu/ (0x00007f1a5a4c5000)
    /lib64/ (0x00007f1a5a8a5000)

    Version information:
    ./testendian: (GLIBC_2.2.5) => /lib/x86_64-linux-gnu/
    /lib/x86_64-linux-gnu/ (GLIBC_2.3) => /lib64/ (GLIBC_PRIVATE) => /lib64/

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/ 
GNU C Library (Ubuntu EGLIBC 2.15-0ubuntu10) stable release version 2.15, by Roland McGrath et al.
share|improve this answer
I did know about ldd, didn't know you could just run a library though - thanks. Unfortunately my output from running the library doesn't show the version.... – mathematician1975 Jul 13 '12 at 13:18
Disregard that I was being an idiot - thanks for the answer! – mathematician1975 Jul 13 '12 at 13:19
Thanks for the answer. Can you provide some information what the ldd output tells me? Does it mean that testendian requires GLIBC_2.3 or GLIBC_2.2.5? – bonanza Jul 6 at 6:55
I'm reasonably sure, it means that the program needs GLIBC 2.2.5 and the library loader ld-linux-x86-64 was build with GLIBC_2.3. So both in a way. But take that with a grain of salt, as I didn't find a reference. – con-f-use Jul 6 at 7:52

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.