Re: creating dynamic objects with Python

Steven D. Majewski (sdm7g@elvis.med.virginia.edu)
Tue, 16 Aug 1994 12:43:56 -0400

On Aug 16, 7:52, Lance Ellinghouse wrote:
>
> My system finally has dynamic linking and I would like to turn most
> of the "optional" modules into dynamic libraries.
>
> I build my shared object using the following line:
>
> cc -O -K i486 -K pic -belf -G -I.. -I../Include -DHAVE_CONFIG_H -c rotormodule.c -o rotormodule.so -lm
>
> This builds correctly. And creates a .so file that is about 10k.
> Then when I try to import it, it complains that it cannot find things
> like 'newobject'.
>
> If I link against all the Python libs, then I get a .so file that is
> about 240K and it still cannot find some things...
>
> What do other people do?
>

As Guido stated, this should not be a problem on SunOS, but I had a
similar problem with the AIX dynamic loading.

AIX linker uses explicit export and import lists. There are required
if the dynamically loaded module needs to resolve symbols in the main
program. What I have done is to make one link pass and dump out the
list of unresolved symbols, and turn this list into an export/import
list for another attempt at linking. This sometimes requires relinking
the main program. The better solution ( which I haven't gotten around
to doing yet ) would be to make all of modsupport and probably some
other common routines into a sharable library, to which both the
main program and the other dynamic libraries are linked.

When you get the large but non-working 240k .so file, you are
probably linking in some support modules into both the main program
and the dynamic module. You've got two parallel namespaces. Python
objects have their own dynamic dispatch tables, so there can be
symbols that still aren't getting resolved in one namespace because
they are done at runtime. ( The details could vary with how your
linker and dynamic loading works, but, again, I ran into similar
symptoms when I first tried this on AIX. )

- Steve Majewski (804-982-0831) <sdm7g@Virginia.EDU>
- UVA Department of Molecular Physiology and Biological Physics