Question About Embedding into C++
jlj at cfdrc.com
Wed May 17 17:53:29 EDT 2000
I've used SWIG to wrap a C++ library. The source files for my extension
get compiled using the "-fPIC" flag to gcc to ensure that it produces
position-independent code; the shared object is linked with the
"-shared" flag. The end-product is a shared object. If I import this
extension module using the stand-alone Python interpreter executable,
all is well and everything works as expected. I should note that these
are the standard Python executable and library (libpython1.5.a)
installed with Red Hat Linux 6.1, if that matters.
Now I would like to embed the Python interpreter in a C++ application,
and from within that application, import the previously described
extension module. But when I execute this code:
the program shuts down and the error message (raised from Python) is:
Traceback (innermost last):
File "<string>", line 1, in ?
File "../FXPy/__init__.py", line 21, in ?
File "../FXPy/fox.py", line 2, in ?
ImportError: foxcmodule.so: undefined symbol: _Py_NoneStruct
So I searched the web and read the Python FAQ, and I'm seeing hints of
this problem in other settings (e.g. Gnumeric's Python plugin), but
nothing conclusive. Can anyone clue me in to the basic problem?
Remember, it works OK when "Python is on top" and I'm just running the
stand-alone Python interpreter.
Any suggestions are greatly appreciated!
Thanks in advance,
Lyle (jlj at cfdrc.com)
More information about the Python-list