[Python-Dev] LynxOS4 dynamic loading with dlopen() and -ldl
Mon, 21 Apr 2003 19:27:38 -0500
I'm unable to get the dynamic Python modules to import/load
correctly on LynxOS4 (a realtime OS that has gcc, shared libs,
and many other UNIXisms).
platform = lynxos4 (my comment in setup.py)
building 'struct' extension
gcc -DNDEBUG -g -O3 -Wall -Wstrict-prototypes -fvec -fPIC -mshared
-mthreads -I. -I/usr/local/src/Python-2.2.2/./Include
gcc -shared -mshared -mthreads
-L/usr/local/lib -o build/lib.lynxos-4.0.0-PowerPC-2.2/struct.so
WARNING: removing "struct" since importing it failed
(all the other modules fail the same way)
I hacked setup.py to stop "removing" the bad module files and brought
up the python interpreter to try the import by hand:
Python 2.2.2 (#4, Apr 21 2003, 16:39:51)
[GCC 2.95.3 20010323 (Lynx)] on lynxos4
Type "help", "copyright", "credits" or "license" for more information.
>>> import sys
>>> sys.path += ['/usr/local/src/Python-2.2.2/build/lib.lynxos-4.0.0-PowerPC-2.2']
>>> import struct
Traceback (most recent call last):
File "<stdin>", line 1, in ?
ImportError: Symbol not found: "PyInt_Type"
(btw, it would be nice if 'ImportError: Symbol not found: "PyInt_Type"'
was emitted without all the debugging by hand -- actually it would be
nice if many python exceptions (IndexError: list index out of range
comes to mind) were rather more helpful about what is wrong, all this
debugging via divination is a bit hard on us newbies!)
PyInt_Type is declared in Objects/intobject.o and is visible in
the python binary (the one doing the dlopen()). I'm not that familiar
with dlopen() but shouldn't references from the .so being loaded to
the loading program be resolved by dlopen during load? Running nm
on 'python' gives '004d2d3c D PyInt_Type' so all the python symbols
are being exported properly.
Any ideas on how to resolve this run-time symbol lookup error?
LynxOS seems to shy away from shared libraries (they live in
a special nonstandard directory and not all libraries have shared
versions). Should I be thinking about doing a static python? If
so, I will need to abandon dlopen() completely right? But I also
want to use tkinter and the X11 libs to so I don't think static is
really what I want!