[C++-sig] boost::python PyUnicodeUCS4_FromEncodedObject

Venkatraman S venkat83 at gmail.com
Thu Mar 27 14:10:07 CET 2008


Am stumbling on a very rudimentary problem and am totally not able to
proceed. Googling did not help me much and hence am trying to state the
problem in its entirety.  Any quick comments/hints would be highly helpful.

Am getting the following error when i try to import the module (class) into
python :

>>> import myClass
*Traceback (most recent call last):
  File "<stdin>", line 1, in ?
ImportError: ./myClass.so: undefined symbol: PyUnicodeUCS4_FromEncodedObject

g++ (GCC) 4.0.0 20050519 (Red Hat 4.0.0-8)
Python 2.4.3

*Other Information:*
$ldd myClass.so
        libstdc++.so.6 => /usr/lib/libstdc++.so.6 (0x00db8000)
        libm.so.6 => /lib/tls/libm.so.6 (0x002b3000)
        libgcc_s.so.1 => /lib/libgcc_s.so.1 (0x00eb7000)
        libpthread.so.0 => /lib/tls/libpthread.so.0 (0x0057a000)
        libc.so.6 => /lib/tls/libc.so.6 (0x00b6f000)
        /lib/ld-linux.so.2 (0x00712000)
Files Used :*

#include <boost/python.hpp>
#include <boost/python/def.hpp>
#include <boost/python/tuple.hpp>
#include <boost/python/dict.hpp>
#include <boost/python/module.hpp>
#include <boost/python/raw_function.hpp>
#include <string>

class Var
  int value;
  std::string name;
  Var(std::string n)

std::string processObj(boost::python::object x)
 Var obj=boost::python::extract<Var>(x);
 return obj.name;

using namespace boost::python;
 class_<Var>("Var", init<std::string>())
  .def_readonly("name", &Var::name)
  .def_readwrite("value", &Var::value);

 def("processObj", processObj);

from distutils.core import setup
from distutils.extension import Extension

$python setup.py build

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/cplusplus-sig/attachments/20080327/390cbc18/attachment.htm>

More information about the Cplusplus-sig mailing list