I am trying to create a standalone application from Python code. At the moment, this is just a hello world program. I will compile it with Cython to get the .c file:
"c: \ python34 \ scripts \ cython.exe" --embed hello.py
It works great. 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
This gives me a lot of errors in the links:
... \ cc7PmSei.o: hello.c :(. text + 0xe9): undefined link 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
Additional Information: I have a 64-bit Windows 7 Home OS. I am using 32-bit 32-bit, Cython-0.20.1 and TDM-GCC 4-bit Python 3.4.1.
I did some research. Some people say that this can be caused, for example, using a 32-bit C compiler and 64-bit Python. But this is not the case here. Others ( http://eli.thegreenplace.net/2008/06/28/compiling-python-extensions-with-distutils-and-mingw/ ) say I need to create libpython34.a. But my version of Python has already appeared with this file.
Does anyone have an idea what I'm doing wrong? Thanks in advance.