Newbie: Undefined reference when initializing Python

henrikb666 evil_wicked at ofir.dk
Wed Mar 13 12:54:11 EST 2002


Please bear with me: I'm a hobby programmer who has been coding C and 
C++ for a couple of years under Linux RH 6.2 and I just know how to 
use Emacs and the most useful commands under Linux.

Now I'd like to use Python embedded in a C++ program, but am not sure 
the program is installed properly.
This is what I did so far:

1. DOwnload the V2.2 Python tar.gz
2. gunzip
3. tar -xvf
4. ./configure
5. make
6. as root: make install

THe idea is now to do the following from the C++ code:

void TServer::boot(void)
{
  ...

  // Initialize Python.
  Py_Initialize();

  ...
}

But this error occurs:

[pos at localhost mymud]$ make
g++ -I/home/pos/mymud/include/ -I/home/pos/xerces-c1_6_0-
linux/include/ -I/home/pos/Python-2.2/ -I/home/pos/Python-
2.2/Include -g -c src/TServer.cc
g++ -g -o mymud main.o TServer.o TDesc.o TChar.o TWorld.o Utility.o 
TCommand.o Constants.o TBase.o TPc.o TRoom.o TExit.o TMob.o 
TMobProtoFactory.o TZone.o Movement.o TXMLHandler.o TEvent.o -
L/home/pos/xerces-c1_6_0-linux/lib -lxerces-c1_6_0
TServer.o: In function `TServer::boot(void)':
/home/pos/mymud/src/TServer.cc:85: undefined reference to 
`Py_Initialize'
collect2: ld returned 1 exit status
make: *** [mymud] Error 1

I already include <Python.h> at the top of the TServer.cc file, so 
that's not it. Could it have something to do with my Makefile?

Any help is appreciated as a search for "newbie" in the archive here 
didn't turn up anything relevant to this problem.

Thanks for reading,
Henrik Jensen





More information about the Python-list mailing list