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
dylib @executable_path path issue in a plug-in bundle
提问by moala
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:
我正在开发一个插件包,比如说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) 上运行?谢谢。
回答by moala
From the web and other SO questions: use @loader_path/..
instead of @executable_path/..
. See:
来自网络和其他 SO 问题:使用@loader_path/..
而不是@executable_path/..
. 看: