embedding python, missing symbols

Two Inches missedby2inches at gmx.net
Sat Jan 25 06:08:41 EST 2003


Jack Diederich wrote:
> I can't seem to make gcc happy
> 
> using the example main() from the embedding docs and doing
> 
> gcc -I<path to Python.h> ./libpython2.2.a example.c

Use -L to tell gcc where to search for libs and -l to tell it which libs 
to link against.

something like this should work (not tested; I do prefer to separate 
compiling and links as a matter of taste):

gcc -o example.o -I<path to Python.h> example.c
gcc example.o -o example -L<path to Python-libs> -lpython2.2

You may also want to read some decent (g)cc documentation.
> 
> gives the following error
> 
> /tmp/ccBiGJVU.o: In function `main':
> /tmp/ccBiGJVU.o(.text+0x2d): undefined reference to `Py_Initialize'
> /tmp/ccBiGJVU.o(.text+0x3d): undefined reference to `PyString_FromString'
> /tmp/ccBiGJVU.o(.text+0x50): undefined reference to `PyImport_Import'
> <snip, more of the same>
> /tmp/ccBiGJVU.o(.text+0x299): undefined reference to `Py_Finalize'
> 
> ./libpython2.2.a is a hard link to the one installed in /usr/local 
> 
> I tried with python2.2 and 2.3a1
> I tried with gcc 2.96 and 3.0.4
> 
> redhat 7.1 with recompiled pythons and gccs
> 
> grepping the libpython* binaries shows a match for all the symbols
> 
> similar errors on groups.google are because the libpython*.a wasn't
> included.  I am including the lib ... gcc just doesn't care.
> 
> I must be missing something obvious, please let me know what it is!
> 
> btw, mod_python and other things compile happilly on the same machine.
> 
> TIA,
> 
> -jackdied
> 





More information about the Python-list mailing list