15

Is there a tool like Windows DependencyWalker for Ubuntu ? I would like to see all shared libraries my executable depends on.

tommyk
  • 4,576

2 Answers2

24

In a terminal, execute:

ldd /path/to/your_executable

Example:

~$ ldd /bin/ls
        linux-vdso.so.1 =>  (0x00007fff78fea000)
        libselinux.so.1 => /lib/libselinux.so.1 (0x00007f1940858000)
        librt.so.1 => /lib/librt.so.1 (0x00007f1940650000)
        libacl.so.1 => /lib/libacl.so.1 (0x00007f1940447000)
        libc.so.6 => /lib/libc.so.6 (0x00007f19400c4000)
        libdl.so.2 => /lib/libdl.so.2 (0x00007f193fec0000)
        /lib64/ld-linux-x86-64.so.2 (0x00007f1940a99000)
        libpthread.so.0 => /lib/libpthread.so.0 (0x00007f193fca2000)
        libattr.so.1 => /lib/libattr.so.1 (0x00007f193fa9d000)
perseo22
  • 1,066
  • There is one big difference beween ldd and depends - ldd does not show the hierarchy of dependencies. A shared library that I built links to 2 different versions of libicu, and I am unable to figure out which of the SOs that my library depends on is dependent on the "wrong" version. Is there some trick to have that hierarchical view? – kritzel_sw Nov 24 '21 at 14:31
1

ldd only shows which shared libraries the given executable depends on, but – much unlike Dependency Walker – it does not show you the symbols (e.g. functions) that are imported from each shared library. If you want to know which symbols an executable (or shared library) imports, you can use nm with options -D --undefined-only. This still does not tell you which specific functions are imported from which specific library. There is a script that can do this, though:

https://github.com/dEajL3kA/dependencies.py

Note: You may want to use option --recursive to also resolve indirect decencies! This will give you a "hierarchical" view of the dependencies, sort of what Dependency Walker does.


lddtree, available from the pax-utils package, provides a "tree" view of ldd output.

Hokimba
  • 11