mmf wrote: > Hallo! > > I tried to use Python from C like it is described in the Python > Docmentation. So I wrote the following C source file: > > #include <Python.h> > int > main(int argc, char *argv[]) > { > Py_Initialize(); > PyRun_SimpleString("print 'Hallo World!'\n"); > Py_Finalize(); > return 0; > } > > I saved it as run.c and tried to compile it using the following > command: > gcc run.c > > But that always results in a list of errors: > > /tmp/cc1tmrPU.o(.text+0x1d): In function `main': > : undefined reference to `Py_Initialize' > /tmp/cc1tmrPU.o(.text+0x2a): In function `main': > : undefined reference to `PyRun_SimpleString' > /tmp/cc1tmrPU.o(.text+0x32): In function `main': > : undefined reference to `Py_Finalize' > > What am I doing wrong? Can you help me? > > Tanks. > > Best regards, > Markus >
You should link with Python's shared object (replace with your version of Python): gcc -o run run.c -I/usr/include/python2.4 -lpython2.4 -- Are you a riddle lover? Try http://www.pythonchallenge.com -- http://mail.python.org/mailman/listinfo/python-list