Embedding python with mingw compilers

Rod Stephenson viking_kiwi at yahoo.poofters.com
Sat Apr 3 17:57:02 EST 2004


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;
}


 
-- 
Rule 1. 



More information about the Python-list mailing list