I'm trying to build standalone application from Python code. At the moment it is only a "hello world" program. I compile it with Cython to get a .c file:
"c:\python34\scripts\cython.exe" --embed hello.py
That works fine. Then I try to compile and link the generated .c file as follows:
"c:\mingw32\bin\gcc.exe" -I"c:\python34\include" -L"c:\python34\libs" -lpython34 -ohello.exe hello.c
That gives me a whole lot of link errors:
...\cc7PmSei.o:hello.c:(.text+0xe9): undefined reference to `_imp__PyTuple_New'
...\cc7PmSei.o:hello.c:(.text+0x130): undefined reference to `_imp__PyBytes_FromStringAndSize'
...\cc7PmSei.o:hello.c:(.text+0x177): undefined reference to `_imp__PyModule_Create2'
...
...\cc7PmSei.o:hello.c:(.text+0x12b7): undefined reference to `_imp__PyUnicode_Decode'
...\cc7PmSei.o:hello.c:(.text+0x12dd): undefined reference to `_imp__PyUnicode_FromStringAndSize'
...\cc7PmSei.o:hello.c:(.text+0x1303): undefined reference to `_imp__PyBytes_FromStringAndSize'
.../libmingw32.a(main.o):main.c:.text.startup+0xa7): undefined reference to `WinMain@16'
collect2.exe: error: ld returned 1 exit status
Some more info: I have Windows 7 Home 64-bit OS. I use Python 3.4.1 32-bit, Cython-0.20.1, and TDM-GCC 4.7.1 32-bit.
I did some research. Some people say that it can be caused for example by using 32-bit C compiler and 64-bit Python. But it is not the case here. Other (http://eli.thegreenplace.net/2008/06/28/compiling-python-extensions-with-distutils-and-mingw/) say that I need to create libpython34.a. But my version of Python already came with this file.
Does anyone have an idea what I do wrong? Thanks in advance.