Cython: How to compile to 32bit Windows with MinGW gcc? - Printable Version +- Python Forum (https://python-forum.io) +-- Forum: Python Coding (https://python-forum.io/forum-7.html) +--- Forum: General Coding Help (https://python-forum.io/forum-8.html) +--- Thread: Cython: How to compile to 32bit Windows with MinGW gcc? (/thread-10453.html) |
Cython: How to compile to 32bit Windows with MinGW gcc? - PythonABC - May-21-2018 I converted my Python code with Cython to c code. To convert the c code to an executable I use the gcc of "MinGW-w64 - for 32 and 64 bit Windows". The compilation to a working 64bit Windows exe works but not to a working 32bit Windows exe. This is what I have done so far: I downloaded MinGW from https://sourceforge.net/projects/mingw-w64/files/?source=navbar. On their site they write: "MinGW-w64 - for 32 and 64 bit Windows" Also I cannot find there a special MinGW32 version. So I assume the MinGW64 gcc compiler can compile to 64 AND 32 bit Windows. I used Cython to convert my py to a c file. I installed Python 3.7 64 bit in C:\Python37 and Python 3.7 32 bit in C:\Python37-32bit The following works and I get a 64bit exe that I can start without errors: gcc -Wl,--subsystem,windows -municode -DMS_WIN64 -mthreads -Wall -O -IC:\Python37\include -LC:\Python37\libs example.c -lpython37 -o example.exe (The -Wl,--subsystem,windows is to prevent a Dos windows.) I read the parameter m32 in gcc is to get a 32 bit exe. So I tried this: gcc -Wl,--subsystem,windows -m32 -municode -DMS_WIN64 -mthreads -Wall -O -IC:\Python37-32bit\include -LC:\Python37-32bit\libs example.c -lpython37 -o example.exe I get no compile error. But if I start the example.exe I get a windows with this error message: (Tried to translate my German message to English:) example.exe - Application error The application couldn't started correctly (0xc000007b). Click on 'OK' to close the application. OK Also I tested it with -m32 but without -Wl,--subsystem,windows if there are side effects because both parameter have to do with Windows. But then I get the same error message if I start example.exe. I use tkinter in my program. Can that be a reason I get an error message if I start the 32bit Windows example.exe? This is my program example.py that I converted to a c file with Cython an then to exe with the gcc of MinGW: #Example (Hello, World): import tkinter tk = tkinter.Tk() frame = tkinter.Frame(tk, relief="ridge", borderwidth=2) frame.pack(fill="both",expand=1) label = tkinter.Label(frame, text="Hallo Welt!") label.pack(expand=1) button = tkinter.Button(frame,text="OK",command=tk.destroy) button.pack(side="bottom") tk.mainloop()So anybody knows why I can compile to a working 64 bit exe with MinGW gcc but not to a working 32 bit exe? What have I to do to get a working 32 bit exe with MinGW gcc? |