Erreur d'importation sur le programme boost python hello

inclure

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)
    ;
}

Compiler et générer ok

~/boost$ g++ -fPIC -I/usr/include/python2.6 -c hello.cpp 
~/boost$ g++ -shared hello.o -o hello.so

Mais lors de l'importation à partir de python côté, a reçu l'erreur.

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

Quelqu'un peut-il m'aider? Merci à l'avance.

source d'informationauteur user216056 | 2009-11-22