Embedded Python Linking Problem
Ian Terrell
kife00 at yahoo.com
Tue Feb 25 16:16:42 EST 2003
I'm experimenting with embedding Python in C++ programs as explained
in http://www.python.org/doc/current/ext/embedding.html. I'm having
some trouble linking, however.
I'm running an i686 system with Red Hat 8, using gcc 3.2 and Python
2.2.
The C++ program is:
-----
#include <python2.2/Python.h>
int main()
{
Py_Initialize();
PyRun_SimpleString("print \"Hello, world!\"");
Py_Finalize();
return 0;
}
-----
It compiles cleanly, but can't resolve linking:
$ g++ hello.cc -o hello
/tmp/ccGyP0Vj.o: In function `main':
/tmp/ccGyP0Vj.o(.text+0x11): undefined reference to `Py_Initialize'
/tmp/ccGyP0Vj.o(.text+0x1e): undefined reference to
`PyRun_SimpleString'
/tmp/ccGyP0Vj.o(.text+0x26): undefined reference to `Py_Finalize'
collect2: ld returned 1 exit status
A grep in /usr/lib/python2.2/ yields:
$ grep "Py_Initialize" * */*
Binary file config/libpython2.2.a matches
But, I've attempted to add libpython2.2.a in a few ways to g++, to no
avail.
Anyone have any help?
Thanks!
Ian
More information about the Python-list
mailing list