Problem extending python through dynamic loading

Simeon H. Fitch (shf2d@henson.cs.virginia.edu)
Tue, 12 Apr 1994 01:42:04 GMT

I am currently writing a module that implements a new class in Python,
but instead of compiling it into Python I want it to be dynamically
loaded at run-time. I am working on a Sun Sparc10 using g++ to
compile my module code and ld to create my dynamic object file. If my
module consists of only one file, i.e. one .C file to one .o file, I
have _no_ problem loading it into python at run-time. However, if I do
something like:

ld $(LIB) -o loadtestmodule.so object1.o object2.o

(where LIB has all the python libraries needed, like libObjects.a, etc.)

causes ld.so (from inside Python) to give me the error:

ld.so: Undefined symbol: ___builtin_new

If I do:

nm -u loadtestmodule.so

no unresolved names are reported.

I searched through all of the Python libraries for a definition of
_builtin_new but found nothing like that. The interesting thing is
that if you actually search through the .so file (through all the hex
munge), __builtin_new comes up in the two object file case, but not in
the single object file case.

I have burned about 8 hrs on this problem and am running out of things
to try. The intelligent thing for me to have done would be to have
asked one of you if it is at all to do this, but I kept learning cool
things about python and dynamic objects. :-)

So, any relevant anecdotes that you might have about your experience with
dynamic loading in Python would be greatly apprieciated.

Thanks!

-Simeon-

-- 

+---------------------------------------------------------------------+ | Simeon H. Fitch Department of Computer Science | | fitch@Virginia.EDU University of Virginia | +---------------------------------------------------------------------+

Johann Gambolputty de von Ausfernschplenden schlitter crascrendon fried digger dingle dangle dongle dungle burstein von knacker thrasher apple banger horowitz ticolensic grander knotty spelltinkle grandlich grumblemeyer speltwasser kurstlich himbleeison bahnwagen gutenabend bitte ein nurnburger bratwustle gerspurten mitz weimache luber hundsfut gumberaber schvnendanker kalbsfleisch mittler aucher von Hautkopft of Ulm