Michael P. Reilly
arcege at shore.net
Sat Jun 26 04:14:46 CEST 1999
John Fisher <jfisher at are.berkeley.edu> wrote:
: Hey folks,
: I'm having a bit of trouble loading a C extension into Python 1.5.2.
: I'm getting the error:
: Traceback (innermost last):
: File "<stdin>", line 1, in ?
: File "bpinter.py", line 9, in ?
: PyBPMPD = imp.load_dynamic('PyBPMPD', 'PyBPMPD.so')
: ImportError: ./PyBPMPD.so: undefined symbol: setdef
: setdef, not written by me, but called from inside PyBPMPD.c, is
: prototyped as:
: extern int setdef(bpmparam *);
: The module itself compiles without complaint with:
: gcc -I/usr/include/python1.5/ -shared -o PyBPMPD.so PyBPMPD.c
: I'd appreciate any ideas on the problem. I'm rather stumped.
It sounds like "setdef" is in some library that you are not compiling
with. Or "setdef" was typed incorrectly in your code: resolving
symbols in shared objects is performed at runtime.
When compiling the shared object, you must include library being
referenced (the one that contains "setdef"). Preferably, that
library will be a static library (.a), or you would have to set
LD_LIBRARY_PATH (or LIBPATH on some systems) to point to the
correct location at run-time.
If the library is /usr/local/lib/libdef.so or /usr/local/lib/libdef.a,
then add "-L/usr/local/lib -ldef" to the gcc command you have.
More information about the Python-list