dylib @executable_path插件包中的路径问题 [英] dylib @executable_path path issue in a plug-in bundle
问题描述
我正在开发插件包,例如针对应用程序的MyPlugIn.bundle
,例如BigApp.app
. 此捆绑包需要一个dylib ,例如MyPlugIn.bundle/Contents/Resources/library.dylib
.我已经重新定位了library.dylib的路径,就像我为一个简单的应用程序捆绑包所做的那样:
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)
[...]
但是BigApp.app无法加载此捆绑包,Mac OS X的Console.app记录以下内容:
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
似乎@executable_path 不会由MyPlugIn.bundle可执行文件路径代替,而是由 BigApp.app可执行文件路径代替.
It seems that @executable_path is not replaced by the MyPlugIn.bundle executable path but by the BigApp.app executable path.
对此有任何解决方法,没有绝对路径,以便它可以在 Mac OS X 10.4(老虎)上运行?谢谢.
Any workaround to that, without absolute path and so that it will work on Mac OS X 10.4 (Tiger)? Thanks.
推荐答案
在网络上以及其他一些SO问题:使用@loader_path/..
而不是@executable_path/..
.参见:
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/
- 如何分发带有依赖项的Mac OS X库?
- 安装IB插件
- 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
这篇关于dylib @executable_path插件包中的路径问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!