views:

1133

answers:

3

Hi,

On Windows there is a tool Depends.exe to discover dependency of an EXE/DLL file on other DDLs. Which commandline tool is equivalent on Mac OS and Linux? Please kindly advise. Thank you!

+4  A: 

try ldd in the terminal. This will provide you a list of dynamic libraries that the binary needs.

chuan
Thank you for the prompt reply! It was as simple as:ldd /path/to/executable_or_dyliband the verbose version:ldd -v /path/to/executable_or_dylib
Viet
It runs perfectly for executables. When I run ldd aDynamicLib.so in Ubuntu 9.04, it says: "not a dynamic executable". How to discover dependencies of a .so file? Thank you in advance!
Viet
+8  A: 
  • Mac OS X: otool -L file
  • Linux: ldd file

If those commands don't provide what you want, on Mac OS X you can dump all the load commands with
otool -l file. On Linux you can dump the entire contents of the dynamic section with readelf -d file.

mark4o
Wow! It works great! Thank you so much!
Viet
+2  A: 

You can also try MacDependency (http://macdependency.googlecode.com) which provides an UI replacement for otool on MacOS X. It shows complete dependency trees and the exported symbols as well.

Konrad
thanks very much Konrad! I'll give it a try.
Viet