While trying to overcome the error during importing my shared library hello.so
into python
(as described in Import Error on boost python hello program) I followed the advice from one of the answers, i.e. trying to compile with following two lines:
g++ -c -fPIC -I boost_1_59_0/ -I /usr/include/python2.7/ hello.cpp -o hello.o
g++ -I boost_1_59_0/ -I /usr/include/python2.7/ -shared -Wl,-soname,hello.so -o hello.so hello.o -lpython2.7 -lboost_python
The first line works; the second, however, produces the error:
/usr/bin/ld: cannot find -lboost_python
collect2: error: ld returned 1 exit status
After some googling I tried to substitute -lboost_python
with -lboost_python-py27
or -lboost_python2.7
. Nevertheless, the result is the same.
If I omit the last parameter, I get the error in python
:
>>> import hello
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: ./hello.so: undefined symbol: _ZNK5boost6python7objects21py_function_impl_base9max_arityEv
I work under Ubuntu 14.04.3 LTS
and use python 2.7.6
.
Can someone help me to compile the library correctly?