0

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.)

glennr
  • 2,069
  • 2
  • 26
  • 37
  • I think [this](http://stackoverflow.com/questions/4934806/python-how-to-find-scripts-directory) is what you're looking for. – Travis Oct 06 '14 at 23:12

1 Answers1

0

No, there's no way to control @executable_path from within the executable. @executable_path is resolved by dyld, the dynamic loader, and it uses the path of the executable that it loaded. 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.

Ken Thomases
  • 88,520
  • 7
  • 116
  • 154
  • Thanks for that. I fixed it by changing \@executable_path to \@rpath in the Ogre build scripts. The odd thing is that it was working fine until yesterday. The only thing I can think of that may have broken it was updating CMake to 3.0.2. – glennr Oct 07 '14 at 02:06