(Help) Embedding in Python 1.5

HH henrykhecht at my-deja.com
Mon Apr 1 19:16:59 EST 2002


This seems to be almost a FAQ, but I still can't find a comprehensive
enough answer to get it to work....

I'm trying to embed some Python in some C.  Python version 1.5, as
packaged by Red Hat (not that that should make a difference), and I'm
having a little trouble getting the right linker options.  Basically,
what I've got so far is:

gcc -L/usr/lib/python1.5/config -lpython1.5 -lieee -ldl -lpthread \
		-lm -o testpy testpy.o

which spews a few screenfuls about things from </python1.5/Python.h>
being undefined.  Looking at section 5.6 of "Extending and Embedding
the Python Interpreter", I queried python with:

>>> import distutils.sysconfig
>>> distutils.sysconfig.get_config_var('LINKFORSHARED')
'-rdynamic'

'-rdynamic' means -Wl,--export-dynamic to gcc I believe, though you
will find this nowhere in the gcc documentation.  Unfortuantely,
adding -rdynamic (or -Wl,--export-dynamic or -Xlinker --export-dynamic)
to the above command line seems to do...nothing.

Unfortunately the Python docs don't get any more verbose about this,
and the copy of "Programming Python" I have lying around includes a
very helpful example makefile for Python 1.3, referencing four
libraries that I don't have at all (Modules, Python, Objects, and
Parser).

What am I missing here?  Could someone supply me with a modern (but
not too modern, i.e. 2.x) example makefile, or at least some advice?

-- 
HH



More information about the Python-list mailing list