HELP for embedding Python in C prog
dag4004
dag4004 at caramail.com
Thu Oct 25 12:15:15 EDT 2001
hello,
I want to embedded Python in a C prog. I try with the Programming Python
(O'REILLY).
Here is the exemple : basic1.c
#include <Python.h>
int main(void)
{
Py_Initialize();
PyRun_SimpleString("a=1");
PyRun_SimpleString("print a");
return 0;
}
the makefile
PY = /usr/src/Python-2.1.1
PLIBS = $(PY)/libpython2.1.a
basic1: basic1.o
gcc -g basic1.o $(PLIBS) -lm -o basic1
basic1.o: basic1.c
gcc basic1.c -c -g -I$(PY)/Include -I$(PY)/.
And what i get :
# make
gcc -g basic1.o /usr/src/Python-2.1.1/libpython2.1.a -lm -o basic1
/usr/src/Python-2.1.1/libpython2.1.a(posixmodule.o): In function
`posix_tmpnam':/usr/src/Python-2.1.1/./Modules/posixmodule.c:4212: the use
of `tmpnam_r' is dangerous, better use `mkstemp'
/usr/src/Python-2.1.1/libpython2.1.a(posixmodule.o): In function
`posix_tempnam':
/usr/src/Python-2.1.1/./Modules/posixmodule.c:4168: the use of `tempnam' is
dangerous, better use `mkstemp'
/usr/src/Python-2.1.1/libpython2.1.a(dynload_shlib.o): In function
`_PyImport_GetDynLoadFunc':
/usr/src/Python-2.1.1/Python/dynload_shlib.c:86: undefined reference to
`dlopen'/usr/src/Python-2.1.1/Python/dynload_shlib.c:94: undefined
reference to `dlerror'
/usr/src/Python-2.1.1/Python/dynload_shlib.c:72: undefined reference to
`dlsym'
/usr/src/Python-2.1.1/Python/dynload_shlib.c:99: undefined reference to
`dlsym'
/usr/src/Python-2.1.1/libpython2.1.a(thread.o): In function
`PyThread_start_new_thread':
/usr/src/Python-2.1.1/Python/thread_pthread.h:135: undefined reference to
`pthread_create'
/usr/src/Python-2.1.1/Python/thread_pthread.h:159: undefined reference to
`pthread_detach'
/usr/src/Python-2.1.1/libpython2.1.a(posixmodule.o): In function
`posix_openpty':
/usr/src/Python-2.1.1/./Modules/posixmodule.c:1754: undefined reference to
`openpty'
/usr/src/Python-2.1.1/libpython2.1.a(posixmodule.o): In function
`posix_forkpty':
/usr/src/Python-2.1.1/./Modules/posixmodule.c:1785: undefined reference to
`forkpty'
collect2: ld returned 1 exit status
make: *** [basic1] Erreur 1
Does some one understand what goes wrong ?
HELP
Damien
More information about the Python-list
mailing list