Fix missing libraries of an existing Mac OS binary by adding a correct @rpath command

  • Post published:April 8, 2016

Adding missing library path to an existing OS X binary:
For example: open tracker (see misses the correct relative @rpath:
otool -l /Applications/ | grep @rpath
name @rpath/QtWidgets.framework/Versions/5/QtWidgets (offset 24)
name @rpath/QtGui.framework/Versions/5/QtGui (offset 24)
name @rpath/QtNetwork.framework/Versions/5/QtNetwork (offset 24)
name @rpath/QtCore.framework/Versions/5/QtCore (offset 24)

Where @rpath is at:
Load command 28
cmdsize 56
path /Users/sthalik/dev/opentrack/build/install (offset 12)
Load command 29
cmdsize 56
path /Users/sthalik/Qt5.5.1/5.5/clang_64/lib (offset 12)

Wrong path set for local Qt’s libraries

In order to fix this: we should add a custom @rpath for all libraries not being deployed with the executable or being linked with libs only being locally available:
For example adding local Qt libs to opentracker.bin:
install_name_tool -add_rpath /Applications/Qt/5.5/clang_64/lib /Applications/

More generally speaking:
install_name_tool -add_rpath “absolute path to libs to be added to the executable” “absolute path to the executable”

Check the results:
otool -l /Applications/
Load command 32
cmdsize 48
path /Applications/Qt/5.5/clang_64/lib (offset 12)