ImportError dynamic module does not define init function (boost.python)

时间:2018-11-13 07:50:51

标签: python c++ boost-python

Thank you for see this topic. I tried to use boost.python but now this error happens.

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

I checked some questions in web and some answers said that BOOST_PYTHON_MODULE name and filename must be the same. (ex. this page said) But I have already done it.

This is my code lattice.h,

BOOST_PYTHON_MODULE(latticepy)
{
  using namespace boost::python;
  class_<lattice::Lattice>("Lattice")
    .def("loadProperties", &lattice::Lattice::loadProperties)
    .def("train", &lattice::Lattice::train)
    .def_readonly("hmm_", &lattice::Lattice::hmm_);
}

and build code.

g++ -I`python -c 'from distutils.sysconfig import *; print get_python_inc()'` -DPIC -shared -fPIC -o latticepy.so lattice.h -g -O0 -lfst -ldl -lboost_system -lboost_python -std=c++11 -lpython2.7

0 个答案:

没有答案