I have installed MinGW-w64 for compiling to 64-bit. But it appears that I have to install two seperate versions of MinGW-w64 to get support for 32-bit.
I tried that, using batch files and powershell scripts and what not, and it wasn't very good in the end.
There appears to be multilib version which can handle both using the -m32
flag for 32-bit although I am not sure if that is the how I should compile for both 64-bit and 32-bit.
So what is the proper way get MinGW-w64 to be able to compile for both 64 and 32 bit?
MinGW-w64 is a free and open source C library for targetting Windows 32-bit and 64-bit platforms. The combination of these results in a free C/C++ compiler for Windows.
Now in order to compile with 32-bit gcc, just add a flag -m32 in the command line of compiling the 'C' language program. For instance, to compile a file of geek. c through Linux terminal, you must write the following command with -m32 flag. After that you will be able to compile a 32-bit binary on a 64-bit system.
Although (currently) offering only a 32-bit compiler suite, all of MinGW's software will execute on the 64bit Windows platforms.
You can inspect the output of gcc -v or you can use the more direct option -dumpmachine . The first option allows you to discover if GCC is capable of multilib (so that it can compile both 32 and 64-bit binaries), the second option will only return the default target (if I am not mistaken).
The version you are using is not multilib
enabled so you won't be able to compile 32-bit
programs using the MinGW-w64.
You need this version for using it on a 64-bit
platform but in order to be able to compile both 32-bit
and 64-bit
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With