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 workaroun开发者_开发技巧d to that, without absolute path and so that it will work on Mac OS X 10.4 (Tiger)? Thanks.
From the web and other SO questions: use @loader_path/..
instead of @executable_path/..
. See:
- http://developer.apple.com/mac/library/documentation/Darwin/Reference/ManPages/man1/dyld.1.html
- http://lapcatsoftware.com/blog/2007/08/11/embedding-frameworks-in-loadable-bundles/
- How to distribute a Mac OS X with dependent libraries?
- Installing IB plugin
精彩评论