18

In OS X using either a GUI or CLI tool how can I find out the version info of a given dylib?

2 Answers 2

17

You can use otool (/usr/bin/otool) to see the names and version numbers of the shared libraries that a Mach-O object file uses.

MacPro:~ mdouma46$ otool -L /usr/lib/libssl.0.9.7.dylib 
/usr/lib/libssl.0.9.7.dylib:
  /usr/lib/libssl.0.9.7.dylib (compatibility version 0.9.7, current version 0.9.7)
  /usr/lib/libcrypto.0.9.7.dylib (compatibility version 0.9.7, current version 0.9.7)
  /usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 169.3.0)

MacPro:~ mdouma46$ otool -L /usr/lib/libssl.0.9.8.dylib 
/usr/lib/libssl.0.9.8.dylib:
  /usr/lib/libssl.0.9.8.dylib (compatibility version 0.9.8, current version 47.0.0)
  /usr/lib/libcrypto.0.9.8.dylib (compatibility version 0.9.8, current version 47.0.0)
  /usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 169.3.0)

MacPro:~ mdouma46$ otool -L /usr/lib/libgutenprint.2.dylib 
/usr/lib/libgutenprint.2.dylib:
  /usr/lib/libgutenprint.2.dylib (compatibility version 4.0.0, current version 4.0.0)
  /usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 111.0.0)
  /usr/lib/libgcc_s.1.dylib (compatibility version 1.0.0, current version 1.0.0)

MacPro:~ mdouma46$ otool -L /usr/lib/libcurl.4.dylib 
/usr/lib/libcurl.4.dylib:
  /usr/lib/libcurl.4.dylib (compatibility version 7.0.0, current version 7.0.0)
  /usr/lib/libssl.0.9.8.dylib (compatibility version 0.9.8, current version 47.0.0)
  /usr/lib/libcrypto.0.9.8.dylib (compatibility version 0.9.8, current version 47.0.0)
  /System/Library/Frameworks/LDAP.framework/Versions/A/LDAP (compatibility version 1.0.0, current version 2.4.0)
  /System/Library/Frameworks/Kerberos.framework/Versions/A/Kerberos (compatibility version 5.0.0, current version 6.0.0)
  /usr/lib/libz.1.dylib (compatibility version 1.0.0, current version 1.2.5)
  /usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 169.3.0)

It's not always perfect, but if you provide any specific cases you're trying to figure out, I could advise further.

Unfortunately, it appears that otool isn't part of the default install, but is available as part of the Command Line Tools module of the Xcode developer tools. There are 2 ways to acquire otool:

The first way is might be the easiest, but will require downloading the 1.5 GB worth of Xcode.app on top of the 100 MB of the Command Line Tools. The possible upside of this method is that may help automate the download and install of the Command line tools. The second way requires setting up a free Developer account (unless you already have a paid one) at https://developer.apple.com/programs/register/ (NOTE: option 1 may even require this, I'm not sure, as I'm already a paid member), then connect to https://developer.apple.com/downloads/ and download the appropriate Command Line Tools for Xcode from the list of downloads.

If you go the first route, get Xcode in the app store at https://itunes.apple.com/us/app/xcode/id497799835?ls=1&mt=12.

1
  • Thanks! That appears to work for .dylibs. I tried it on /opt/local/bin/ffmpeg but it doesn't give the version number of ffmpeg itself. Is it possible to get the version number for an executable? (A generic solution that doesn't make use of some sort of command argument such as --version or the like would be preferred.) Nov 14, 2012 at 23:52
1

Another way to get version numbers of executables that went the extra mile and embedded an Info.plist "file" inside the executable (Xcode can do that automatically, for instance) is to use this command:

otool -P /path/to/file

I've given a practical example over on SO.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .