How do I create 32bit executables with mingw-w64?

I'm able to successfully create 64-bit executables with the mingw-w64 compiler in my Windows (64-bit) cmd prompt:

g++ main.cpp -o App

I properly added the the correct Environment variable:

1
2
 
C:\Program Files\mingw-w64\x86_64-6.1.0-posix-sjlj-rt_v5-rev0\mingw64\bin 


Is there way I to create 32bit executables using the same mingw-w64 compiler? Perhaps there's a flag I need to add after g++?


Last edited on
I found the answer :)

Just add a -m32 flag after g++.

Example:

1
2
 
g++ -m32 main.cpp -o App32


Bonus:

I transferred the exe over to my 32 bit machine, but got a bunch of "missing DLL errors". Just add a couple of flags at the end like the following:

1
2
 
g++ -m32 main.cpp -o App32 -static-libgcc -static-libstdc++ -Wl,-Bstatic -lstdc++ -lpthread -Wl,-Bdynamic


Sources:
-m32: http://dlbeer.co.nz/articles/mingw64.html
DLL Errors: http://stackoverflow.com/questions/13768515/how-to-do-static-linking-of-libwinpthread-1-dll-in-mingw
Last edited on
Topic archived. No new replies allowed.