I wrote a small example to show what's going on.
my_test.cpp
#include <iostream>
#include <boost/python/numpy.hpp>
namespace np = boost::python::numpy;
int my_Foo()
{
Py_Initialize();
np::initialize();
std::cout << "hello\n";
return 0;
}
BOOST_PYTHON_MODULE(my_test)
{
using namespace boost::python;
def("my_Foo", my_Foo);
}
py_test.py
import my_test as t
t.my_Foo();
I compile all with command :
g++ -shared -fPIC -o my_test.so my_test.cpp -lboost_python -lpython2.7 -I/usr/include/python2.7
And I get this error :
ImportError: /home/my_test.so: undefined symbol: _ZN5boost6python5numpy10initializeEb
And it works when I comment this line
//np::initialize();
I have no idea how to fix it. I have read similar questions on the forum, but none of the solutions helped me. I tried update boost, update python, link libraries, put generated module before other module during compilation - nothing helps. I will be grateful for any help.