|
Boost Users : |
From: Venkatraman S (venkat83_at_[hidden])
Date: 2008-03-27 09:00:31
Hi,
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 :
$python
>>> import myClass
*Traceback (most recent call last):
File "<stdin>", line 1, in ?
ImportError: ./myClass.so: undefined symbol: PyUnicodeUCS4_FromEncodedObject
*
*Environment:*
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 :*
*myClass.cpp*
-------------
#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
{
public:
int value;
std::string name;
Var(std::string n)
{
name=n;
value=10;
}
};
std::string processObj(boost::python::object x)
{
Var obj=boost::python::extract<Var>(x);
return obj.name;
}
using namespace boost::python;
BOOST_PYTHON_MODULE(myClass)
{
class_<Var>("Var", init<std::string>())
.def_readonly("name", &Var::name)
.def_readwrite("value", &Var::value);
def("processObj", processObj);
}
*setup.py*
---------------
from distutils.core import setup
from distutils.extension import Extension
setup(name="myvaarg",ext_modules=[Extension("myvaarg",["sample.cpp
"],libraries=["boost_python"])])
$python setup.py build
-- Venkat
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