插件包中的dylib @executable_path路径问题

时间:2010-01-19 15:07:12

标签: xcode plugins dylib install-name-tool

我正在开发插件包,对应用程序说MyPlugIn.bundle ,比如说BigApp.app此捆绑包需要dylib ,比如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无法加载此捆绑包,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)上运行?感谢。