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
    Possible duplicate of [boost\_python import error: module does not define init function](https://stackoverflow.com/questions/8400244/boost-python-import-error-module-does-not-define-init-function) – Alan Birtles Aug 14 '19 at 10:40
  • That was it. Many thanks! –  Aug 14 '19 at 10:47

0 Answers0