Programs compiled for Linux normally use shared libraries rather than being statically linked. The advantage to this is that it'll save disk spaces as programs don't need to include libraries in their package. The disadvantage to this is that a program compiled for one system, might not work on another system (distribution) as libraries might not be identically configured on different systems.

The program ldd can be used to display shared libraries used by a program, along with the path of where the library is expected to be found in the filesystem.

The following example shows dependencies of the program bash in a 64 bit machine:

$ ldd /bin/bash
linux-vdso.so.1 =>  (0x00007fff8a372000)
        libncurses.so.5 => /lib/libncurses.so.5 (0x00007fa53a974000)
        libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007fa53a770000)
        libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007fa53a3db000)
        /lib64/ld-linux-x86-64.so.2 (0x00007fa53abe2000)

To display more information and to not need to type the program's full path, run the command as the following.

$ ldd -v `which bash`
        linux-vdso.so.1 =>  (0x00007fff855ff000)
        libncurses.so.5 => /lib/libncurses.so.5 (0x00007f0cc4c11000)
        libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007f0cc4a0d000)
        libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f0cc4678000)
        /lib64/ld-linux-x86-64.so.2 (0x00007f0cc4e7f000)

        Version information:
        /bin/bash:
                libdl.so.2 (GLIBC_2.2.5) => /lib/x86_64-linux-gnu/libdl.so.2
                libc.so.6 (GLIBC_2.4) => /lib/x86_64-linux-gnu/libc.so.6
                libc.so.6 (GLIBC_2.8) => /lib/x86_64-linux-gnu/libc.so.6
                libc.so.6 (GLIBC_2.3) => /lib/x86_64-linux-gnu/libc.so.6
                libc.so.6 (GLIBC_2.11) => /lib/x86_64-linux-gnu/libc.so.6
                libc.so.6 (GLIBC_2.3.4) => /lib/x86_64-linux-gnu/libc.so.6
                libc.so.6 (GLIBC_2.2.5) => /lib/x86_64-linux-gnu/libc.so.6
        /lib/libncurses.so.5:
                libdl.so.2 (GLIBC_2.2.5) => /lib/x86_64-linux-gnu/libdl.so.2
                libc.so.6 (GLIBC_2.4) => /lib/x86_64-linux-gnu/libc.so.6
                libc.so.6 (GLIBC_2.3) => /lib/x86_64-linux-gnu/libc.so.6
                libc.so.6 (GLIBC_2.3.4) => /lib/x86_64-linux-gnu/libc.so.6
                libc.so.6 (GLIBC_2.2.5) => /lib/x86_64-linux-gnu/libc.so.6
        /lib/x86_64-linux-gnu/libdl.so.2:
                ld-linux-x86-64.so.2 (GLIBC_PRIVATE) => /lib64/ld-linux-x86-64.so.2
                libc.so.6 (GLIBC_PRIVATE) => /lib/x86_64-linux-gnu/libc.so.6
                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_PRIVATE) => /lib64/ld-linux-x86-64.so.2
                ld-linux-x86-64.so.2 (GLIBC_2.3) => /lib64/ld-linux-x86-64.so.2
Leave your feedback:
Share!