小编use*_*056的帖子

在boost python hello程序上导入错误

包括

using namespace boost::python;

struct World{
    void set(std::string msg) { this->msg = msg; }
    std::string greet() { return msg; }
    std::string msg;
};

BOOST_PYTHON_MODULE(hello)
{
    class_<World>("World")
        .def("greet", &World::greet)
        .def("set", &World::set)
    ;
}
Run Code Online (Sandbox Code Playgroud)

编译并构建好

~/boost$ g++ -fPIC -I/usr/include/python2.6 -c hello.cpp 
~/boost$ g++ -shared hello.o -o hello.so
Run Code Online (Sandbox Code Playgroud)

但是当从python端导入时,出错了.

>>> import hello.so
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: ./hello.so: undefined symbol: _ZNK5boost6python7objects21py_function_impl_base9max_arityEv
>>> 
Run Code Online (Sandbox Code Playgroud)

有谁能够帮我?提前致谢.

python boost

17
推荐指数
3
解决办法
1万
查看次数

如何在javascript中使用函数(1)(2)?它是如何工作的?

我理解调用函数(1)而不是函数(1)(2),它是如何工作的?

功能(1)(2)(3)(4)也可以吗?

javascript function

6
推荐指数
1
解决办法
538
查看次数

标签 统计

boost ×1

function ×1

javascript ×1

python ×1