uso inseguro de la ruta relativa libboost.dylib al hacer la demostración boost.python helloword?
Recientemente, estoy aprendiendo la biblioteca boost C ++. Quiero usar python para llamar al proyecto C ++ existente. Tengo instalar boost en OSX 10.11 usandobrew install boost
. Mi python versión 2.7.
Hago un hola.c:
char const* greet()
{
return "hello, world";
}
#include <boost/python.hpp>
BOOST_PYTHON_MODULE(hello)
{
using namespace boost::python;
def("greet", greet);
}
y Makefile:
PYTHON_VERSION = 2.7
PYTHON_INCLUDE = /usr/include/python$(PYTHON_VERSION)
# location of the Boost Python include files and library
#
BOOST_INC = /usr/local/include
BOOST_LIB = /usr/local/lib
#
# compile mesh classes
TARGET = hello
$(TARGET).so: $(TARGET).o
g++ -shared -Wl $(TARGET).o -L$(BOOST_LIB) -lboost_python -L/usr/lib/python$(PYTHON_VERSION)/config -lpython$(PYTHON_VERSION) -o $(TARGET).so
$(TARGET).o: $(TARGET).c
g++ -I$(PYTHON_INCLUDE) -I$(BOOST_INC) -fPIC -c $(TARGET).c
Sin embargo, después de corrermake
y recibí hola.so. Me encontré con el siguiente error cuando ejecuto el código de Python:
import hello
print hello.greet()
error:
Traceback (most recent call last):
File "test.py", line 4, in <module>
import hello
ImportError: dlopen(/Users/einverne/boost_test/hello.so, 2): Library not loaded: libboost_python.dylib
Referenced from: /Users/einverne/boost_test/hello.so
Reason: unsafe use of relative rpath libboost_python.dylib in /Users/einverne/boost_test/hello.so with restricted binary