I have an application written in Python that uses Ogre3D via a C++ wrapper module. 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
I am running it from the directory where MyOgreWrapper.so is located so that MyOgreWrapper.so can be found by Python. Ogre.framework is located in ../Frameworks relative to the location of MyOgreWrapper.so.
$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.
Is there a way to set up the environment from Python so that @executable_path is the current directory?
(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.)