导入Boost Python模块时出错(函数\u impl_base9max_arityEv)

2024-05-16 13:57:07 发布

您现在位置:Python中文网/ 问答频道 /正文

我试图用Booost Python构建一个hello World C++ ++ Python扩展。在

我从https://www.mantidproject.org/Boost_Python_Introduction获得以下源代码:

 // test.cpp
 #include <iostream>
 #include <boost/python.hpp>


 void sayHello()
 {
   std::cout << "Hello, Python!\n";
 }

 BOOST_PYTHON_MODULE(test)  // Name here must match the name of the final shared library, i.e. mantid.dll or mantid.so
 {
    boost::python::def("sayHello", &sayHello);
 }

但是,当我尝试使用以下命令进行编译时:

^{pr2}$

此命令成功编译代码并创建库文件测试.so. 在

但是,当我尝试在python3中导入模块时,我得到以下错误:

<> >强>恐怖/ /home /yt/C++测试.so:未定义符号:_ZNK5boost6python7objects21py函数_impl_base9max_arityEv

链接Import Error on boost python hello program似乎建议使用该命令 我使用上面的方法可以通过添加-I/usr/include/python3.6m-I/lib64/libboost_python3来解决问题,但它没有。在

我做错什么了?在

谢谢!在

操作系统:Fedora 29 x86_64


Tags: thehttpstest命令helloworldsoinclude