Embedding python with mingw compilers

R

Rod Stephenson

I'm successfully created python extensions on windows using the mingw
compiler (with swig), now I'm trying to embed python in a c-program.

The simple example (included below) is from the manual. I compile it
with gcc 3.2.3:


gcc -o pytest -Ic:/python23/include -Lc:/python23/libs -lpython23 pytest.c

I then get error messages for the python calls, eg

C:\WINDOWS\TEMP/ccU2vhgb.o(.text+0x5b):pytest.c:
undefined reference to `_imp__Py_Initialize'

I notice however that the .def file I used to create libpython23.a
does have references to _imp__Py_Initialize (as well as Py_Initialize)
and these also seem to be in the generated library file.

Any suggestions as to what else needs to be done to sort this out?



********************

#include <Python.h>
int
main(int argc, char *argv[])
{
Py_Initialize();
PyRun_SimpleString("from time import time,ctime\n"
"print 'Today is',ctime(time())\n");
Py_Finalize();
return 0;
}
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,962
Messages
2,570,134
Members
46,690
Latest member
MacGyver

Latest Threads

Top