我正在开发一个插件包,比如说MyPlugIn.bundle
,是为了一个应用程序,比如说BigApp.app
。这个包需要一个动态库,比如说MyPlugIn.bundle/Contents/Resources/library.dylib
。我已经重新定位了library.dylib
的路径,就像我对简单的应用程序包所做的那样。
$ 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)
[...]
但是BigApp.app无法加载这个bundle,Mac OS X的Console.app记录了以下内容:
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
似乎 @executable_path 没有被 MyPlugIn.bundle 可执行文件路径所取代,而是被 BigApp.app 可执行路径 取代了。
有没有解决方法可以避免使用绝对路径,同时能在 Mac OS X 10.4(Tiger) 上运行?谢谢。