Saturday, July 3, 2010

How to check shared libraries used by an application and add news ones?

To check which libraries are used, use the ldd command. ldd prints the shared libraries required by each program or shared library specified on the command line.

E.g.
ldd /path/to/file


To add new library files, use ldconfig. "ldconfig creates, updates, and removes the necessary links and cache (for use by the run-time linker, ld.so) to the most recent shared libraries found in the directories specified on the command line, in the file /etc/ld.so.conf, and in the trusted directories (/usr/lib and /lib). ldconfig checks the header and file names of the libraries it encounters when determining which versions should have their links updated. ldconfig ignores symbolic links when scanning for libraries."

After adding new libraries (.so) files to /usr/lib, run sudo ldconfig and that should do it.
Check if the newly added files are used by your binaries by running ldd.

An example output:
[dummy-linux ~]$ ldd /bin/ls
        linux-vdso.so.1 =>  (0x00007fff005ff000)
        libselinux.so.1 => /lib64/libselinux.so.1 (0x0000003538800000)
        librt.so.1 => /lib64/librt.so.1 (0x0000003538000000)
        libcap.so.2 => /lib64/libcap.so.2 (0x000000353ac00000)
        libacl.so.1 => /lib64/libacl.so.1 (0x0000003545800000)
        libc.so.6 => /lib64/libc.so.6 (0x0000003537000000)
        libdl.so.2 => /lib64/libdl.so.2 (0x0000003537400000)
        /lib64/ld-linux-x86-64.so.2 (0x0000003536800000)
        libpthread.so.0 => /lib64/libpthread.so.0 (0x0000003537800000)
        libattr.so.1 => /lib64/libattr.so.1 (0x0000003545000000)

0 comments:

Post a Comment