0

I have made a module using Boost.Python.

#include <boost/python.hpp>

double product(const long a,  const double x){
  return a*x;
}

void square(const long n, const double* x, double* x2){
  for(long i=0; i<n; ++i){
    x2[i]=x[i]*x[i];
  }
}

BOOST_PYTHON_MODULE(test)
{
  boost::python::def("product", product);
  boost::python::def("square", square);
}

I have compiled it using:

g++ test.cpp -fPIC -shared -I/usr/include/python2.7 -lpython2.7 -lboost_python -o libtest.so

Unfortunately, when I try to import the module, I obtain the following error message:

ImportError: dynamic module does not define init function (initlibwrapper)

Thanks!

2

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.