[英]Can I set @executable_path from Python
I have an application written in Python that uses Ogre3D via a C++ wrapper module. 我有一个用Python编写的应用程序,它通过C ++包装器模块使用Ogre3D。 When attempting to run my application
尝试运行我的应用程序时
python /path/to/myapp.py
I get the error 我得到错误
dlopen(./MyOgreWrapper.so, 2): Library not loaded: @executable_path/../Frameworks/Ogre.framework/Versions/1.9.0/Ogre Referenced from: /path/to/MyOgreWrapper.so Reason: image not found
dlopen(./ MyOgreWrapper.so,2):库未加载:@executable_path /../ Frameworks / Ogre.framework / Versions / 1.9.0 / Ogre引用自:/path/to/MyOgreWrapper.so原因:找不到图像
I am running it from the directory where MyOgreWrapper.so is located so that MyOgreWrapper.so can be found by Python. 我从MyOgreWrapper.so所在的目录中运行它,以便可以通过Python找到MyOgreWrapper.so。 Ogre.framework is located in ../Frameworks relative to the location of MyOgreWrapper.so.
Ogre.framework相对于MyOgreWrapper.so的位置位于../Frameworks中。
$otool -l MyOgreWrapper.so
MyOgreWrapper.so:
@rpath/MyOgreWrapper.so (compatibility version 0.0.0, current version 0.0.0)
@executable_path/../Frameworks/Ogre.framework/Versions/1.9.0/Ogre (compatibility version 1.9.0, current version 1.9.0)
...
I suspect that this happens because @executable_path is set to the path of the python executable. 我怀疑这是因为@executable_path设置为python可执行文件的路径。
Is there a way to set up the environment from Python so that @executable_path is the current directory? 有没有一种方法可以从Python设置环境,以便@executable_path是当前目录?
(I know that it will all work if I change the path for Ogre in MyOgreWrapper.so and a few other dependencies to @loader_path but that is not how it comes out of the box and I'd rather not have to do that.) (我知道,如果我在MyOgreWrapper.so中将Ogre的路径以及其他一些依赖项更改为@loader_path,这一切都会起作用,但这不是开箱即用的方式,我宁愿不必这样做。)
No, there's no way to control @executable_path
from within the executable. 不,无法从可执行文件内控制
@executable_path
。 @executable_path
is resolved by dyld
, the dynamic loader, and it uses the path of the executable that it loaded. @executable_path
由动态加载程序dyld
解析,它使用它加载的可执行文件的路径。 It's fixed for any given executable. 它对于任何给定的可执行文件都是固定的。
Also, if you could change it, that would probably break other stuff that the process attempts to load. 另外,如果可以更改它,则可能会破坏该进程尝试加载的其他内容。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.