Boost Python Numpy - Undefined reference to initialize

Viewed 1071

I am having problems when linking the following code:

#include <boost/python.hpp>
#include <boost/python/numpy.hpp>

BOOST_PYTHON_MODULE (MyLibrary)
{

    Py_Initialize() ;
    boost::python::numpy::initialize() ;

    ...

}

which returns:

undefined reference to `boost::python::numpy::initialize(bool)'

I am using Boost 1.68 with Python 3.6, compiled as follows:

./bootstrap.sh --with-python=/usr/bin/python3 --with-python-version=3.6 --with-python-root=/usr/lib/python3.6
./b2 --with-python link=shared install

And I am linking using:

/usr/bin/c++ -shared
-o MyLibrary.so
MyLibrary.cpp.o
-L/usr/local/lib
-lpython3.6m
/usr/local/lib/libboost_python36.so

Any idea...?

1 Answers

The solution was to install the python3-numpy package first, otherwise libboost_numpy.so does not get generated.

End of the story!

Related