Tracking dependencies of a library in Mac

otool is a command-line tool shipped with Xcode and can do things similar to Dependency Walker in Windows.

Where is it located?

/Applications/Xcode.app/Contents/Developer/usr/bin

How to use it?

For instance, to know all the dependencies of libcurl dylib the following can be done:

cd to /Applications/Xcode.app/Contents/Developer/usr/bin

$ ./otool -L /usr/lib/libcurl.dylib

Result:

  /usr/lib/libcurl.4.dylib (compatibility version 7.0.0, current version 7.0.0)

   /usr/lib/libresolv.9.dylib (compatibility version 1.0.0, current version 46.1.0)

   /usr/lib/libssl.0.9.8.dylib (compatibility version 0.9.8, current version 49.1.0)

   /usr/lib/libcrypto.0.9.8.dylib (compatibility version 0.9.8, current version 49.1.0)

   /usr/lib/libz.1.dylib (compatibility version 1.0.0, current version 1.2.5)

   /System/Library/Frameworks/LDAP.framework/Versions/A/LDAP (compatibility version 1.0.0, current version 2.2.0)

   /System/Library/Frameworks/Kerberos.framework/Versions/A/Kerberos (compatibility version 5.0.0, current version 6.0.0)

   /usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 159.1.0)

NOTE:

1. Use ./ as otool path is not set in PATH

2. Use -L option to display names and versions of dependent shared libraries

3. One can also inspect object files using otool

150 150 Burnignorance | Where Minds Meet And Sparks Fly!