Need help porting a C++ / Python Embedded app to multiple platforms

J

jpw

I am writing a Python / C++ embed app and it need to work on 3
platforms

I have the PYTHONPATH variable set correctly and have gone back and
downloaded compiled and installed the latest Python 2.5.1 on Solaris
and Linux. adding in the --enable-shared when running the ./
configure ... file

Mac - good to go there was no need do anything except update to 2.5
and add the PYTHONPATH

Solaris 10 -
Linux - Errors occur in the same point at runtime as soon as I try to
do load a module
The load module code is as follows:

PyObject* name = PyString_FromString(moduleName.c_str());
PyObject* mModule = PyImport_Import(name);
Py_DECREF(name);

if (mModule == 0)
{
std::eek:stringstream oss;
oss << "Failed to load module <" << moduleName << ">";
throw PythonException(oss.str());
}


both errors indicate a problem with libc.so

LINUX error stacktrace:

terminate called after throwing an instance of

'PythonWrapper::pythonException'
what(): N13PythonWrapper15PythonExceptionE

Program received signal SIGABRT, Aborted.
[Switching to Thread 1161832800 (LWP 16508)]
0x00000033f332e21d in raise () from /lib64/tls/libc.so.6
(gdb) where
#0 0x00000033f332e21d in raise () from /lib64/tls/libc.so.6
#1 0x00000033f332fa1e in abort () from /lib64/tls/libc.so.6
#2 0x0000002a96360a20 in __gnu_cxx::__verbose_terminate_handler ()
at ../../../../gcc-4.0.4/libstdc++-v3/libsupc++/vterminate.cc:97
#3 0x0000002a9635ea66 in __cxxabiv1::__terminate (handler=0x405f)
at ../../../../gcc-4.0.4/libstdc++-v3/libsupc++/eh_terminate.cc:43
#4 0x0000002a9635ea93 in std::terminate ()
at ../../../../gcc-4.0.4/libstdc++-v3/libsupc++/eh_terminate.cc:53
#5 0x0000002a9635eb7a in __cxa_throw (obj=<value optimized out>,
tinfo=<value optimized out>, dest=<value optimized out>)
at ../../../../gcc-4.0.4/libstdc++-v3/libsupc++/eh_throw.cc:77
#6 0x00000000005bb73d in PythonWrapper::python::loadModule
(this=0x94f080,
moduleName=@0x45401f90) at PythonWrapper.C:425


SOLARIS call stack:

Program received signal SIGABRT, Aborted.
[Switching to LWP 12]
0xfe7412a4 in _lwp_kill () from /usr/lib/libc.so.1
(gdb) where
#0 0xfe7412a4 in _lwp_kill () from /usr/lib/libc.so.1
#1 0xfe6dfe20 in raise () from /usr/lib/libc.so.1
#2 0xfe6c0040 in abort () from /usr/lib/libc.so.1
#3 0xfe92e64c in __gnu_cxx::__verbose_terminate_handler ()
at ../../../../gcc-4.0.4/libstdc++-v3/libsupc++/vterminate.cc:97
#4 0xfe92bfd8 in __cxxabiv1::__terminate (
handler=0xfe92e438 <__gnu_cxx::__verbose_terminate_handler()>)
at ../../../../gcc-4.0.4/libstdc++-v3/libsupc++/eh_terminate.cc:43
#5 0xfe92c028 in std::terminate ()
at ../../../../gcc-4.0.4/libstdc++-v3/libsupc++/eh_terminate.cc:53
#6 0xfe92c18c in __cxa_throw (obj=<value optimized out>,
tinfo=0x3a3568,
dest=0x272e6c <~PythonException>)
at ../../../../gcc-4.0.4/libstdc++-v3/libsupc++/eh_throw.cc:77
#7 0x0027422c in PythonWrapper::python::loadModule (this=0x46bc48,
moduleName=@0xf5cffb10) at PythonWrapper.C:425

Any help would be greatly appreciated, jpw
 
G

Gabriel Genellina

I am writing a Python / C++ embed app and it need to work on 3
platforms

I have the PYTHONPATH variable set correctly and have gone back and
downloaded compiled and installed the latest Python 2.5.1 on Solaris
and Linux. adding in the --enable-shared when running the ./
configure ... file

Mac - good to go there was no need do anything except update to 2.5
and add the PYTHONPATH

Solaris 10 -
Linux - Errors occur in the same point at runtime as soon as I try to
do load a module
The load module code is as follows:

PyObject* name = PyString_FromString(moduleName.c_str());
PyObject* mModule = PyImport_Import(name);
Py_DECREF(name);

if (mModule == 0)
{
std::eek:stringstream oss;
oss << "Failed to load module <" << moduleName << ">";
throw PythonException(oss.str());
}


both errors indicate a problem with libc.so

I don't think so. You are throwing a C++ exception, nobody is catching it,
and the program aborts. (Python exceptions are handled in a very different
way, see the Python/C API Reference)
You should investigate why you can't import the module. Is the name
correct? (You didn't check the result from PyString_FromString). Is
sys.path correct? Can you import the module from a pure Python script?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,954
Messages
2,570,116
Members
46,704
Latest member
BernadineF

Latest Threads

Top