boost_python import error: module does not define init function

て烟熏妆下的殇ゞ 提交于 2019-11-29 03:08:10
jgoeders

The name used in BOOST_PYTHON_MODULE must match the name of the .so library you generate and import into python.

I have seen this exception before. I got it using Visual Studio on windows, so things might be a little different over in unix-oid land but:

Two Possibilities:

Debug/Release miss-match: You are trying to import a debug build of your module into a release build of python (or vice-versa). The solution is to include boost/python/detail/wrap_python.hpp instead of Python.h. This will fix some includes and defines to make it possible to do what you want.

Python/Boost.Python version miss-match: Boost.Python is compiled against one specific version of python. You are using it with a different version. For example: you seem to be using python 2.7. Your boost_python library might be compiled against python 2.6. Yes, this means that your module can only work with one version of python at a time.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!