Ldd

From Linuxintro
Revision as of 09:55, 24 May 2009 by imported>ThorstenStaerk

ldd is a command that shows which libraries are used by an executable file.

Example
itchy:~ # ldd /usr/local/bin/ktimetracker 
        linux-vdso.so.1 =>  (0x00007fffdb7ff000)
        libkutils.so.4 => /usr/local/lib64/libkutils.so.4 (0x00007feed334b000)
        libkparts.so.4 => /usr/local/lib64/libkparts.so.4 (0x00007feed30fa000)
        libkcal.so.4 => /usr/local/lib64/libkcal.so.4 (0x00007feed2dd7000)    
        [...]

In this case, libkutils is loaded from /usr/local/lib64/libkutils.so.4 to memory address 0x00007feed334b000.

ldd uses the LD_LIBRARY_PATH variable to find out where to search for libraries:

tweedleburg:~/jail # ldd ktimetracker 
        linux-vdso.so.1 =>  (0x00007fffa7dff000)
        libkutils.so.4 => /usr/lib64/libkutils.so.4 (0x00007fa69f8e1000)
        libkparts.so.4 => /usr/lib64/libkparts.so.4 (0x00007fa69f69f000)
tweedleburg:~/jail # export LD_LIBRARY_PATH=.
tweedleburg:~/jail # ldd ktimetracker 
        linux-vdso.so.1 =>  (0x00007fff65fff000)
        libkutils.so.4 => ./libkutils.so.4 (0x00007f595da82000)
        libkparts.so.4 => ./libkparts.so.4 (0x00007f595d831000)

Usage

To find out all files that an executable file depends on:

ldd /usr/local/bin/ktimetracker | sed "s/^.* => //" | sed "s/ (0x.*//"

See also