So I have created two modules using boost::python:
BOOST_PYTHON_MODULE(A) { ... }
BOOST_PYTHON_MODULE(B) { ... }
Such that B depends on A. I then try to call them using the python code:
import sys
sys.path.append('path/to/modules/')
import A
import B
... # python body
Finally I call the python script from terminal:
python path/to/python/script.py
This works perfectly as long as I execute the terminal command from the directory where I installed the boost::python modules. However, if I call it from any other directory I get the error
File "path/to/python/script.py", line 6, in <module>
import B
importError: dlopen(path/to/B.so, 2): Library not loaded: A.so
Referenced from: path/to/B.so
Reason: image not found
Notice, it fails on "import B" so the sys.path.append command is directing it to the correct place. For some reason the boost::python libraries don't look in the sys.path directories? Is there a way to set this? I tried adding the path to in boost python but this seems to only effect things at compile time of the libraries, not with python is running.
Does anyone know what to do?
Thanks!
dlopenis part of theimportbehavior. Without statically linking extensions in the interpreter, how else would the interpreter for a dynamic language load a C++ library?