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++
.
BONUS
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
- inspect directory and file structure of MinGW-w64 installation in hope to locate one of those DLLs (typically in
bin
); or
- build some real or test C++ code involving exception handling to force linkage with one of those DLLs and then see on which one of those DLLs does the built target depend (for example, can be seen with Dependency Walker on Windows); or
- take brute force approach and compile some test code to assembly (instead of machine code) and look for presence of references like
___gxx_personality_v*
(DWARF), ___gxx_personality_seh*
(SEH), ___gxx_personality_sj*
(SJLJ); see Obtaining current GCC exception model.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…