在64位Windows上构buildGMP

我遵循了“适用于Windows平台的GMP安装说明”的说明 。 我可以构build一个可用于Visual Studio的GMP的32位版本。

./configure --prefix=${gmp-install} --disable-static --enable-shared make make install 

然后我在另一台机器(运行64位Windows)上安装了mingw_w64和msys,然后重新运行这些命令。

./configure运行没有任何问题。 但是,当我运行“make”时,我得到了以下结果。

 m4 -DHAVE_CONFIG_H -D__GMP_WITHIN_GMP -DOPERATION_add_n -DDLL_EXPORT -DPIC add_n.asm >tmp-add_n.s gcc -std=gnu99 -c -DHAVE_CONFIG_H -I. -I.. -D__GMP_WITHIN_GMP -I.. -DOPERATION_add_n -O2 -pedantic -fomit-frame-pointer -mno-cygwin tmp-add_n.s -DDLL_EXPORT -DPIC -o .libs/add_n.o tmp-add_n.s: Assembler messages: tmp-add_n.s:84: Error: operand type mismatch for `push' tmp-add_n.s:85: Error: operand type mismatch for `push' tmp-add_n.s:86: Error: operand type mismatch for `push' tmp-add_n.s:107: Error: operand type mismatch for `jmp' tmp-add_n.s:114: Error: operand type mismatch for `pop' tmp-add_n.s:115: Error: operand type mismatch for `pop' tmp-add_n.s:116: Error: operand type mismatch for `pop' make[2]: *** [add_n.lo] Error 1 make[2]: Leaving directory `/d/Temp/gmp-5.0.1/mpn' make[1]: *** [all-recursive] Error 1 make[1]: Leaving directory `/d/Temp/gmp-5.0.1' make: *** [all] Error 2 

如果我用“gmake”代替,则会显示以下错误。

 m4 gcc -DHAVE_CONFIG_H -D__GMP_WITHIN_GMP -DOPERATION_add_n -DDLL_EXPORT -DPIC add_n.asm >tmp-add_n.s m4: gcc: No such file or directory gmake[2]: *** [add_n.lo] Error 1 gmake[2]: Leaving directory `d:/Temp/gmp-5.0.1/mpn' gmake[1]: *** [all-recursive] Error 1 gmake[1]: Leaving directory `d:/Temp/gmp-5.0.1' gmake: *** [all] Error 2 

我不熟悉C ++ make。 我是否需要指定任何标志为了通知mingw_w64我正在为64位构build? 谢谢。

对我来说,gmp是成功构建的x86,而且我在构建x64时遇到了问题。 问题在于:

在mpn \ fib_table.c中:

 #if GMP_NUMB_BITS != 32 Error, error, this data is for 32 bits #endif 

而在gmp.h中:

 #define GMP_LIMB_BITS 64 #define GMP_NAIL_BITS 0 #define GMP_NUMB_BITS (GMP_LIMB_BITS - GMP_NAIL_BITS) 

fib_table.c是由gen-fix.exe工具生成的,这个工具是由make生成的。

所以,如果在构建x86(如我)之后尝试构建x64构建,仅仅首先运行“make clean”是不够的。 运行“make clean”后,删除gmp根文件夹下的所有“gen – *。exe”文件,这个文件将被make重新正确的重建。 之后gmp x64成功地为我建立了。

在gmp 6.0.0上测试。

请参阅http://gladman.plushost.co.uk/oldsite/computing/gmp4win.php ,并注意这一段;

但是,GMP不能在Windows上提供高性能的64位库,因为它的64位汇编代码与Windows x64调用约定不兼容。 这意味着,与MPIR相比,WIndows上的64位GMP库非常慢,MPIR具有出色的64位汇编程序支持。

所以你要么使用./configure --disable-assembly禁用程序./configure --disable-assembly要么使用MPIR 。

我已经尝试了以下。 图书馆可以成功建立。

 ./configure --prefix=/d/Temp/gmp-5.0.1-install --build=x86_64-w64-mingw32 --host=x86_64-w64-mingw32 --disable-static --enable-shared 

你可能想看看MPIR 。 本机支持Visual Studio是GMP的一个分支。