I am using Ubuntu 13.04 and installed mingw-w64 using apt-get install mingw-w64
. I can compile and link a working 64-bit version of my program with the following command:
x86_64-w64-mingw32-g++ code.cpp -o app.exe
Which generates a 64-bit app.exe file.
What binary or command line flags do I use to generate a 32-bit version of app.exe?
MinGW64 is an open source C/C++ compiler for WIndows platforms based on the popular gcc available on Linux and on many other Operating Systems; Mingw64 can create both 32 and 64 bit binary executables.
MinGW can be run either on the native Microsoft Windows platform, cross-hosted on Linux (or other Unix), or "cross-native" on Cygwin. Although programs produced under MinGW are 32-bit executables, they can be used both in 32 and 64-bit versions of Windows.
open a cmd.exe and do set PATH=C:\mingw64\bin;%PATH% for 64-bit building. set PATH=C:\mingw32\bin;%PATH% for 32-bit building. You should be ready to go. Execute i686-w64-mingw32-gcc -v or x86_86-w64-mingw32-gcc -v to see that everything has gone well.
That depends on which variant of toolchain you're currently using. Both DWARF and SEH variants (which come starting from GCC 4.8.0) are only single-target. You can see it yourself by inspecting the directory structure of their distributions, i.e. they contain only the libraries with either 64- or 32-bit addressing, but not both. On the other hand, plain old SJLJ distributions are indeed dual-target, and in order to build 32-bit target, just supply -m32
flag. If that doesn't work, then just build with i686-w64-mingw32-g++
.
By the way, the three corresponding dynamic-link libraries (DLLs) implementing each GCC exception model are
libgcc_s_dw2-1.dll
(DWARF);libgcc_s_seh-1.dll
(SEH);libgcc_s_sjlj-1.dll
(SJLJ).Hence, to find out what exception model does your current MinGW-w64 distribution exactly provide, you can either
bin
); or___gxx_personality_v*
(DWARF), ___gxx_personality_seh*
(SEH), ___gxx_personality_sj*
(SJLJ); see Obtaining current GCC exception model.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