[C++-sig] June 2002 Progress Report

David Abrahams david.abrahams at rcn.com
Tue Jul 23 18:35:46 CEST 2002


It looks like you're missing a destructor definition for your class
"Base"...

HTH,
Dave

----- Original Message -----
From: "chuzo okuda" <okuda1 at llnl.gov>
To: <c++-sig at python.org>
Sent: Tuesday, July 23, 2002 12:16 PM
Subject: Re: [C++-sig] June 2002 Progress Report


> I read and copied code in ...libs/python/doc/v2/call_mehtod.html with
> some modification so as to compile.
> It compiled, but could not import... Please advise me how to fix?
> Thank you...
>
>
> gps02(490) python
> Adding parser accelerators ...
> Done.
> Python 2.2 (#1, Jan 22 2002, 14:39:03) [C] on osf1V5
> Type "help", "copyright", "credits" or "license" for more information.
> >>> import my_module
> Traceback (most recent call last):
>   File "<stdin>", line 1, in ?
> ImportError: dlopen: ./my_module.so: symbol "__T_4Base" unresolved
> [8615 refs]
> >>>
>
> Modified source code:
>
> #include <boost/python/call_method.hpp>
> #include <boost/python/module.hpp>
> #include <boost/python/class.hpp>
> #include <boost/utility.hpp>
> #include <cstring>
> #include <boost/ref.hpp>
>
> // class to be wrapped
> class Base {
> public:
>    virtual char const* class_name() const { return "Base"; }
>    virtual ~Base();
> };
>
> bool is_base(Base* b) {
>    return !std::strcmp(b->class_name(), "Base");
> }
>
> // Wrapper code begins here
> using namespace boost::python;
>
> // Callback class
> class Base_callback : public Base {
> public:
>    Base_callback(PyObject* self) : m_self(self) {}
>
>    char const* class_name() const {
>       return call_method<char const*>(m_self, "class_name");
>    }
>    char const* Base_name() const { return Base::class_name(); }
> private:
>    PyObject* m_self;
> };
>
> using namespace boost::python;
> BOOST_PYTHON_MODULE_INIT(my_module)
> {
>    module("my_module")
>       .def("is_base", is_base)
>       .add(
>            class_<Base,Base_callback, boost::noncopyable>("Base")
>            .def("class_name", Base_callback::Base_name)
>            )
>       ;
> }
>
>
> _______________________________________________
> C++-sig mailing list
> C++-sig at python.org
> http://mail.python.org/mailman/listinfo/c++-sig






More information about the Cplusplus-sig mailing list