Boost logo

Boost Users :

From: antonyc (ac_at_[hidden])
Date: 2008-08-19 13:26:02


I've just started this morning with boost::python and have been struggling
all day to get the basic
http://www.boost.org/doc/libs/1_35_0/libs/python/doc/tutorial/doc/html/python/exposing.html
'exposing classes' doc/tutorial: to link correctly under gcc 4.1.2. I
would greatly appreciate any help as I'm sure it's probably something simple
and I'm pretty much at a loss at the moment.

So the source file compiles and the shared object appears to link ok
however when I try and import the module, python reports the following
missing symbol:

ImportError: /test/BoostPython/hello.so: undefined symbol:
_ZN5boost6python9converter8registry6insertEPFPvP7_objectEPFvS5_PNS1_30rvalue_from_python_stage1_dataEENS0_9type_infoE

de-mangled courtesy of c++filt:

boost::python::converter::registry::insert(void* (*)(_object*), void
(*)(_object*, boost::python::converter::rvalue_from_python_stage1_data*),
boost::python::type_info)

Indeed a search through the boost.python headers yields no such function
prototype. Nor does searching the symbols defined in
libboost_python-gcc41-mt.so.
The closest match I can find in libboost_python-gcc41-mt.so is:

boost::python::converter::registry::insert(void* (*)(_object*), void
(*)(_object*, boost::python::converter::rvalue_from_python_stage1_data*),
boost::python::type_info, _typeobject const* (*)())

which appears to match the following function in
python/converter/registry.hpp:

  // Insert an rvalue from_python converter
  BOOST_PYTHON_DECL void insert(
      convertible_function
      , constructor_function
      , type_info
      , PyTypeObject const* (*expected_pytype)() = 0
      );

Beyond that I'm pretty much stuck. Thanks in advance to anyone who can help
me out!

antony

/*------------------- hello.cpp -------------------*/
#include <string>

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

#include <boost/python.hpp>
using namespace boost::python;

BOOST_PYTHON_MODULE(hello)
{
    class_<World>("World")
        .def("greet", &World::greet)
        .def("set", &World::set)
    ;
}
/*-----------------------------------------------------------*/

g++ -c -g -Wall -fPIC -pipe -DBOOST_PYTHON_MAX_ARITY=20 -I.
-I/usr/local/include -I/usr/local/include/python2.5 hello.cpp
g++ -shared -o hello.so hello.o -L/usr/local/lib -lpython2.5
-lboost_python-gcc41-mt

-- 
View this message in context: http://www.nabble.com/boost.python---undefined-symbol-error-tp19054023p19054023.html
Sent from the Boost - Users mailing list archive at Nabble.com.

Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net