I often find myself curious as to what libraries and frameworks a program relies upon. Thanks to a recent entry by Marc Liyanage, I’ve managed to make this task rather automatic, lifting most of his little command verbatim.

Note that this is a ZSH style alias, but should be trivial to make work with the shell of your choice:

libdepends () { echo Dependencies for: $* otool -L $* | cut -f 1 -d ‘ ‘ | grep -v ‘:’ | xargs -n 1 ls }

When called, you’ll get something similar to the following:

%libdepends =mutt Dependencies for: /usr/local/bin/mutt /usr/lib/libSystem.B.dylib /usr/lib/libssl.0.9.7.dylib /usr/lib/libcrypto.0.9.7.dylib %

Pretty useful, huh? The way it’s written, you’ll get an error (from ls, of course) if any of the shared libraries do not exist. Thanks for this tip, Marc!

Previous Post Next Post