Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Compile for 32-bit Architectures using MinGW-w64

Tags:

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?

like image 397
A. Shahir Avatar asked Jan 10 '20 16:01

A. Shahir


People also ask

Can MinGW-w64 compile 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.

How to compile 32 bits gcc?

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.

Is MinGW only 32-bit?

Although (currently) offering only a 32-bit compiler suite, all of MinGW's software will execute on the 64bit Windows platforms.

Is gcc 32 or 64-bit?

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).


1 Answers

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.

like image 94
TantrixRobotBoy Avatar answered Sep 27 '22 16:09

TantrixRobotBoy