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

Discussion in 'Python' started by jpw, Feb 5, 2008.

  1. jpw

    jpw Guest

    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
     
    jpw, Feb 5, 2008
    #1
    1. Advertising

  2. Re: Need help porting a C++ / Python Embedded app to multipleplatforms

    En Tue, 05 Feb 2008 15:30:28 -0200, jpw <>
    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::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?

    --
    Gabriel Genellina
     
    Gabriel Genellina, Feb 5, 2008
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. gouaich
    Replies:
    1
    Views:
    349
    NigelE
    Jul 18, 2007
  2. David Moss
    Replies:
    3
    Views:
    298
  3. Wilde, Donald S

    porting Ruby to an embedded target

    Wilde, Donald S, May 27, 2011, in forum: Ruby
    Replies:
    4
    Views:
    392
    Wilde, Donald S
    May 31, 2011
  4. Justin Drake

    Porting Python to an embedded system

    Justin Drake, Mar 4, 2012, in forum: Python
    Replies:
    3
    Views:
    1,099
    88888 Dihedral
    Mar 5, 2012
  5. Deron Meranda
    Replies:
    0
    Views:
    224
    Deron Meranda
    Oct 5, 2012
Loading...

Share This Page