xcodepluginsdylibinstall-name-tool

dylib @executable_path path issue in a plug-in bundle


I am developing a plug-in bundle, say MyPlugIn.bundle for an application, say BigApp.app. This bundle requires a dylib, say MyPlugIn.bundle/Contents/Resources/library.dylib. I have relocated paths for library.dylib, as I would have done for a simple application bundle:

$ otool -L MyPlugIn.bundle/Contents/MacOS/MyPlugIn
MyPlugIn.bundle/Contents/MacOS/MyPlugIn:
 @executable_path/../Resources/library.dylib (compatibility version 0.0.0, current version 0.0.0)
 [...]

$ otool -L MyPlugIn.bundle/Contents/Resources/library.dylib
MyPlugIn.bundle/Contents/Resources/library.dylib:
 @executable_path/../Resources/library.dylib (compatibility version 0.0.0, current version 0.0.0)
 [...]

But BigApp.app fails to load this bundle, and Mac OS X's Console.app logs what follows:

19/01/10 15:42:59 BigApp[51516] Error loading /Library/Application Support/BigApp/Plug-Ins/MyPlugIn.bundle/Contents/MacOS/MyPlugIn:  dlopen(/Library/Application Support/BigApp/Plug-Ins/MyPlugIn.bundle/Contents/MacOS/MyPlugIn, 262): Library not loaded: @executable_path/../Resources/library.dylib
  Referenced from: /Library/Application Support/BigApp/Plug-Ins/MyPlugIn.bundle/Contents/MacOS/MyPlugIn
  Reason: image not found

It seems that @executable_path is not replaced by the MyPlugIn.bundle executable path but by the BigApp.app executable path.

Any workaround to that, without absolute path and so that it will work on Mac OS X 10.4 (Tiger)? Thanks.


Solution

  • From the web and other SO questions: use @loader_path/.. instead of @executable_path/... See: