c++windows64-bitgmpmsys2

Building GMP 6.1.0 on 64 bit Windows 7 (msys2/mingw64): configure fails due to mp_limb_t is not 64 bits


I try to build GMP on my Windows 7 64 bit computer, so I run the config.guess and get k10-pc-msys. (I use msys2 and mingw64)

Then I ran

./configure --prefix=/c/gmp-6.1.0 --build=k10-pc-msys --enable-cxx

But this quits with this error

checking size of mp_limb_t... 4
configure: error: Oops, mp_limb_t is 32 bits, but the assembler code
in this configuration expects 64 bits.

So I ran the config again with an additional ABI=64 (thinking to force mp_limb_t to be 64 bit), but this ends in the same error. After this I tried to add CC="g++" (thinking --enable-cxx needs g++), but once again I get this error.

I googled a lot about this and found one issue reported to juliaLang on GitHub that looks close to my problem, but the solution seems not to work for me, since I'm not using Julia.

Does anyone know this error and found a way to fix it?

Notice: I see that msys2 already has installed and I can use it. But the runtime of my program increased by about 70% only from building NTL with the installed GMP from msys2. I think this is because it was not build for my computer so it is not optimized at all.

Edit: Even without any settings (just ./configure --prefix=/c/gmp-6.1.0) does quit with the same error.

Background: I want to use the thread safe build of NTL. But to build NTL thread safe, I have to use GMP.


Solution

  • This is solved by adding --host=x86_64-w64-mingw32 to the configure command. This is generally recommended to build software that uses Autotools or some form of configure script for Windows 64-bit.

    You can read this page on the MinGW-w64 wiki to learn more about these things. Here is the most pertinent quote from that page:

    Triplets and MinGW-w64

    When using the MinGW-w64 cross compilers, while you may need to use different --build triplets, you will only use the --host triplets i686-w64-mingw32 or x86_64-w64-mingw32. Use i686-w64-mingw32 when building for 32-bit Windows platforms, and x86_64-w64-mingw32 when building for 64-bit Windows platforms. When using the MinGW-w64 native compilers, you typically do not need to provide configure any type triplet information.