Why "undefined reference to `Py_Initialize' " error?

Fredrik Lundh fredrik at effbot.org
Mon Feb 5 14:57:08 EST 2001


Bill Xu wrote:
> Please help me with Python embeded C++ problem:
> I compile the following file with gcc -I /usr/local/include/python2.0/
> basic1.c
> It gives me " undefined reference to `Py_Initialize' " error,
> Do I miss some setting in Python 2.0 or miss some package?
> I can't find my Modules, Python ... directorys in my python 2.0 directory.

the library has been called libpython<version>.a for the
last four years, or so...

try changing PY to point to your 2.0 build directory, and
change PLIBS to point to $(PY)/libpython2.0.a

(if you don't have that file, you don't have a full installation.
look for a "development" package, or build Python from the
source tarball)

...and yes:

$ gcc -I /usr/local/include/python2.0/basic1.c

if you have a makefile, you better use "make" to run it,
not "gcc"...  (especially not gcc without the -c flag...)

Cheers /F





More information about the Python-list mailing list