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

Gabriel Genellina gagsl-py2 at yahoo.com.ar
Tue Feb 5 18:35:54 EST 2008


En Tue, 05 Feb 2008 15:30:28 -0200, jpw <johnwalker3301 at comcast.net>  
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::ostringstream 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




More information about the Python-list mailing list