C++ Embedding Problem - Import Error

Jim jbublitzNO at SPAMnwinternet.com
Sat Mar 23 04:42:54 EST 2002


I'm building a plugin module (basically a dynamic library)
under Linux that embeds Python. It links fine and using
PyRun_SimpleFile I can load and run scripts. The scripts
work fine when I import a module (.so) generated with
sip from my own C++ libraries. Where it fails is when
I want to import a non-built-in Python module (in this
case I'm trying 'import time' in the script).

The script fails at runtime with:

ImportError: /usr/lib/python2.1/lib-dynload/timemodule.so:
     undefined symbol: PyExc_IOError

nm says that PyExc_IOError is in libplugin.so as type 'B'
(global, uninitialized data section).

I can also reference the undefined symbol from within my own
C++ code without a problem. I'm using libtool and have
included the switches the Python docs say are required for
all symbols to be exported:

plugin_la_LDFLAGS = -avoid-version -module -no-undefined\
     -Xlinker -export-dynamic

Just to be clear, I'm linking libpython into another .so
lib that's dlopened by an app. There is no possibility of
linking Python directly with the app (or I wouldn't be
writing a plugin in the first place).

Anybody have an idea of what's going on and if/how this
can be fixed?

Jim




More information about the Python-list mailing list