Embeding python with mingw on win32 and python 2.4.4

mani mani.sabri at gmail.com
Mon Jan 28 13:27:16 EST 2008


Hi
I'm bringing up an old story once more! I'm on win32 (winxp sp2)
python 2.4.4. mingw gcc version is 3.4.5. msys is in c:\msys. mingw is
in c:\mingw and python is in c:\pyton24. there is also python24.lib
and libpython24.a in c:\python24\libs.
when I try to compile  this sample code [1] from with command [2] in
msys shell I get the results [3].
this subject was discussed a few times over these years and I tried
everything in the posts and forums that I found and google could
translate with no success. I realy need your suggestion!

Regards,   Mani


[1] Sample code:

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

[2] Command:
$ g++ -I/c/python24/include -I/c/MinGW/include -L/c/python24/libs -L/c/
mingw/lib -lpython24 -shared -mwin32 -o p1 p1.o

[3] Results:
p1.o:p1.cpp:(.text+0x2b): undefined reference to `_imp__Py_Initialize'
p1.o:p1.cpp:(.text+0x39): undefined reference to
`_imp__PyRun_SimpleString'
p1.o:p1.cpp:(.text+0x40): undefined reference to `_imp__Py_Finalize'
collect2: ld returned 1 exit status



More information about the Python-list mailing list