Showing shared library dependencies on linux

October 27, 2022

When debugging problems with shared libraries like "undefined symbol" it is usefull to know what library is needed by what library.

The objdump -x <libwhatever.so> | grep NEEDED command will show all of the shared libraries for a single module but what about the dependencies of all of those?

$ objdump -x kdevpythonlanguagesupport.so  | grep NEEDED
  NEEDED               libkdevpythoncompletion.so
  NEEDED               libkdevpythonduchain.so
  NEEDED               libkdevpythonparser.so
  NEEDED               libKDevPlatformLanguage.so.510

Thankfully there is a neat tool called libtree by haampie on github that does just that.

Just run libtree <libwhatever.so> and you get a nice tree.

$ libtree libkdevpythonparser.so 
libkdevpythonparser.so 
├── libpython3.10.so.1.0 [runpath]
   ├── libpthread.so.0 [ld.so.conf]
   ├── libutil.so.1 [ld.so.conf]
   └── librt.so.1 [ld.so.conf]
├── libKDevPlatformLanguage.so.510 [ld.so.conf]

Very helpful! Thank you!