Why "undefined reference to `Py_Initialize' " error?
Bill Xu
bill.xu at newlix.com
Mon Feb 5 13:59:31 EST 2001
Hi, Buddies:
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.
Please give me some hints! Thanks in advance.
Bill
The makefile with this sample is:
PY = /usr/include/python1.5
PLIBS = $(PY)/Modules/libModules.a \
$(PY)/Python/libPython.a \
$(PY)/Objects/libObjects.a \
$(PY)/Parser/libParser.a
POBJS = $(PY)/Modules/config.o $(PY)/Modules/getpath.o
basic1: basic1.o
cc -g basic1.o $(POBJS) $(PLIBS) -lm -o basic1
basic1.o: basic1.c
cc basic1.c -c -g -I$(PY)/Include -I$(PY)/.
$ gcc -I /usr/local/include/python2.0/ basic1.c
/tmp/ccNyWd2r.o: In function `main':
/tmp/ccNyWd2r.o(.text+0x2d): undefined reference to `Py_Initialize'
collect2: ld returned 1 exit status
#include "Python.h"
char *getprogramname() { return "basic1"; }
main() {
printf("%s\n", getprogramname());
Py_Initialize();
// PyRun_SimpleString("import string");
// PyRun_SimpleString("print string.uppercase");
// PyRun_SimpleString("x = string.uppercase");
// PyRun_SimpleString("print string.lower(x)");
}
More information about the Python-list
mailing list