Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > Need help porting a C++ / Python Embedded app to multiple platforms

Reply
Thread Tools

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

 
 
jpw
Guest
Posts: n/a
 
      02-05-2008
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: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:ythonException'
what(): N13PythonWrapper15PythonExceptionE

Program received signal SIGABRT, Aborted.
[Switching to Thread 1161832800 (LWP 1650]
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:ython::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:ython::loadModule (this=0x46bc48,
moduleName=@0xf5cffb10) at PythonWrapper.C:425

Any help would be greatly appreciated, jpw
 
Reply With Quote
 
 
 
 
Gabriel Genellina
Guest
Posts: n/a
 
      02-05-2008
En Tue, 05 Feb 2008 15:30:28 -0200, jpw <(E-Mail Removed)>
escribió:

> 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: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?

--
Gabriel Genellina

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Embedded Python 3 porting issues when passing FILE* toPyRun_SimpleFile() in Windows mixed-compiler environment Deron Meranda Python 0 10-05-2012 04:13 AM
Porting Python to an embedded system Justin Drake Python 3 03-05-2012 02:14 AM
porting Ruby to an embedded target Wilde, Donald S Ruby 4 05-31-2011 04:09 PM
A service for testing Python code on multiple platforms and versions David Moss Python 3 09-13-2008 02:03 PM
Req: (Free) Embedded Platforms for Education gouaich VHDL 1 07-18-2007 05:15 PM



Advertisments