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

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/2094411/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-14 19:04:36  来源:igfitidea点击:

dylib @executable_path path issue in a plug-in bundle

xcodepluginsdylibinstall-name-tool

提问by moala

I am developing a plug-in bundle, say MyPlugIn.bundlefor 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:

我正在开发一个插件包,比如说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)
 [...]

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

但是 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

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

似乎 @executable_path没有被 MyPlugIn.bundle 可执行路径替换,而是被BigApp.app 可执行路径替换

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

任何解决方法,没有绝对路径,以便它可以在Mac OS X 10.4 (Tiger) 上运行?谢谢。