Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

MinGW GCC -- Single 32-bit and 64-bit cross-compiler?

I've downloaded MinGW with mingw-get-inst, and now I've noticed that it cannot compile for x64.

So is there any 32-bit binary version of the MinGW compiler that can both compile for 32-bit Windows and also for 64-bit Windows?

I don't want a 64-bit version that can generate 32-bit code, since I want the compiler to also run on 32-bit Windows, and I'm only looking for precompiled binaries here, not source files, since I've spent countless hours compiling GCC and failing, and I've given up for a while. :(

like image 971
user541686 Avatar asked Mar 16 '11 08:03

user541686


3 Answers

AFAIK mingw targets either 32 bit windows or 64 bit windows, but not both, so you would need two installs. And the latter is still considered beta.

For you what you want is either mingw-w64-bin_i686-mingw or mingw-w64-bin_i686-cygwin if you want to compile for windows 64. For win32, just use what you get with mingw-get-inst.

See http://sourceforge.net/apps/trac/mingw-w64/wiki/download%20filename%20structure for an explanation of file names.

like image 84
Gunther Piez Avatar answered Sep 28 '22 08:09

Gunther Piez


I realize this is an old question. However it's linked to the many times the question has been repeated.

I have found, after lots of research that, by now, years later, both compilers are commonly installed by default when installing mingw from your repository (i.e. synaptic).

You can check and verify by running Linux's locate command:

 $ locate -r "mingw32.*[cg]++$"

On my Ubuntu (13.10) install I have by default the following compilers to choose from... found by issuing the locate command.

/usr/bin/amd64-mingw32msvc-c++
/usr/bin/amd64-mingw32msvc-g++
/usr/bin/i586-mingw32msvc-c++
/usr/bin/i586-mingw32msvc-g++
/usr/bin/i686-w64-mingw32-c++
/usr/bin/i686-w64-mingw32-g++
/usr/bin/x86_64-w64-mingw32-c++
/usr/bin/x86_64-w64-mingw32-g++

Finally, the least you'd have to do on many systems is run:

$ sudo apt-get install gcc-mingw32

I hope the many links to this page can spare a lot of programmers some search time.

like image 42
L. D. James Avatar answered Sep 28 '22 08:09

L. D. James


for you situation, you can download multilib (include lib32 and lib64) version for Mingw64:

Multilib Toolchains(Targetting Win32 and Win64)

By default it is compiled for 64bit.You can add -m32 flag to compile for 32bit program.

But sadly,no gdb provided,you ought to add it manually.

Because according to mingw-64's todo list, gcc multilib version is done,but gdb multilib version is still in progress,you could use it maybe in the future.

Support of multilib build in configure and in gcc. Parts are already present in gcc's 4.5 version by using target triplet -w64-mingw32.
gdb -- Native support is present, but some features like multi-arch support (debugging 32-bit and 64-bit by one gdb) are still missing features.

mingw-64-todo-list

like image 43
傅继晗 Avatar answered Sep 28 '22 06:09

傅继晗