使用 MinGW 在 Windows 上安装 GMP 时出错

Error when installing GMP on Windows with MinGW

本文关键字:GMP 出错 安装 MinGW Windows 使用      更新时间:2023-10-16

我使用的是WinLibs提供的带有MinGW的Windows10。

我尝试使用Windows平台的GMP安装说明给出的说明安装GMP库。

我已经做过这些

  1. C:/mingw64安装MinGW
  2. C:/MSYS/1.0中安装 MSYS
  3. 下载GMP源并将其提取到D:/desktop/gmp-6.2.0
  4. 运行 MSYS 并将cdD:/desktop/gmp-6.2.0
  5. 运行./configure --prefix="D:/GMP" --disable-static --enable-shared.这将成功生成Makefile,并在控制台中显示以下信息:
configure: summary of build options:
Version:           GNU MP 6.2.0
Host type:         skylake-pc-mingw32
ABI:               64
Install prefix:    D:/GMP
Compiler:          gcc
Static libraries:  no
Shared libraries:  yes
  1. 运行make.进程失败,出现以下错误信息
In file included from set_str.c:57:
set_str.c: In function '__gmpf_set_str':
../gmp-impl.h:4435:29: warning: implicit declaration of function 'localeconv' [-Wimplicit-function-declaration]
4435 | #define GMP_DECIMAL_POINT  (localeconv()->decimal_point)
|                             ^~~~~~~~~~
set_str.c:132:24: note: in expansion of macro 'GMP_DECIMAL_POINT'
132 |   const char  *point = GMP_DECIMAL_POINT;
|                        ^~~~~~~~~~~~~~~~~
../gmp-impl.h:4435:41: error: invalid type argument of '->' (have 'int')
4435 | #define GMP_DECIMAL_POINT  (localeconv()->decimal_point)
|                                         ^~
set_str.c:132:24: note: in expansion of macro 'GMP_DECIMAL_POINT'
132 |   const char  *point = GMP_DECIMAL_POINT;
|                        ^~~~~~~~~~~~~~~~~
make[2]: *** [set_str.lo] Error 1
make[2]: Leaving directory `/d/Desktop/gmp-6.2.0/mpf'
make[1]: *** [all-recursive] Error 1
make[1]: Leaving directory `/d/Desktop/gmp-6.2.0'
make: *** [all] Error 2
  1. 应该运行make install来完成安装,但由于最后一步失败,我不能。

这里有什么问题?我该如何解决它?

我只是自己修复了它。(推断的(问题是,当我完成 MSSYS 安装时,安装后脚本的自动运行失败,我只是忽略了它。

手动运行postinstall.bat后,GMP 库按预期编译。