“Dual-target” MinGW-w64 isn't really dual-target?

后端 未结 2 455
生来不讨喜
生来不讨喜 2020-12-16 16:17

When I try to compile a 32-bit program on a 64-bit host with MinGW-builds:

T:\\mingw64>.\\bin\\g++ -m32 Test.cpp

I get:

         


        
相关标签:
2条回答
  • 2020-12-16 16:55

    For those who are getting this linker error on linux with mingw, you are probably trying to build a 32 bit binary with the 64 bit compiler with the -m32 flag or the other way around it.

    To fix this issue, just compile with i686-w64-mingw32 instead of x86_64-w64-mingw32.

    0 讨论(0)
  • 2020-12-16 17:07

    Although the General Usage Instructions page on MinGW-w64 Wiki claims that the MinGW-builds project supplies dual-target compilers, this is not completely true anymore. The 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. Furthermore, recently it was confirmed on the mailing list of MinGW-builds.

    On the other hand, plain old SJLJ distributions are indeed dual-target. If you get:

    The application was unable to start correctly (0xc000007b). Click OK to close the application.

    when running the 64-bit application produced by these distributions, then you should recall that 0xC000007B is the code of STATUS_INVALID_IMAGE_FORMAT, which is a good evidence that 64-bit application is trying to load 32-bit DLLs. Probably, you have added \bin to PATH, whereas should have added \i686-w64-mingw32\lib64 for 64-bit applications to run properly.

    0 讨论(0)
提交回复
热议问题