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?
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- and 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.