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

16,716

Solution 1

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.

Solution 2

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.

Solution 3

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

Share:
16,716
user541686
Author by

user541686

Updated on July 06, 2022

Comments

  • user541686
    user541686 almost 2 years

    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. :(

  • user541686
    user541686 about 13 years
    Huh, do I can't have something that targets both? What does the -m64 flag do? I couldn't get it to work, but it seemed like it should be able to do something like that...
  • Gunther Piez
    Gunther Piez about 13 years
    You could try -m32 with the win64 compiler.
  • user541686
    user541686 about 13 years
    Yeah I did, but aside from the fact that it's still 64-bit, it didn't work anyway: I got some sort of mismatch or version error (don't have the error text with me right now) with some libraries I think.
  • Jason
    Jason about 9 years
    When I tried -m32 with the win64 compiler it appears to have linked my program against the 64-bit Windows dlls (like kernel32.dll). So my binary is 32-bit, but it's dependent on 64-bit dlls that it is not compatible with.
  • Engineer
    Engineer about 9 years
    Can confirm that idea expressed by @hirschhornsalz does not work. I migrated from mingw32 to mingw64 and so I know that the code compiles in both instances, however when attempting to compile with -m32 from mingw64, various dependencies were not met: libmingwex.a, libmoldname.a, libadvapi32.a, libmsvcrt.a, libpthread.a, libshell32.a, libuser32.a, libkernel32.a, etc. etc. A pity!