Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

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 libc.so.6 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). 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 libc.so.6.

share|improve this question
add comment

1 Answer

up vote 4 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
    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.
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
add comment

Your Answer

 
discard

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.