1 使用Cygwin安装GMP和MFPR
- 1 安装Cygwin
Setup Environment
Install Cygwin, add the following packages to the default installation
gcc-core
gcc-g++
libgcc
m4
make #不知为何安装后在Cygwin根目录下搜不到make程序
cmake
bash
Add the following Environment Variable to the User PATH: C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\VC\Tools\MSVC\14.15.26726\bin\Hostx64\x64
This is so you can use the lib command. Your lib.exe may be located elsewhere.
安装好Cygwin以及一些依赖以后,在其根目录(方便说明记为: CygwinRoot=“D:\CygwinRooto”)下的bin/minnty.exe是其终端入口,然后每次打开该终端,进入的是: C y g w i n R o o t / h o m e / CygwinRoot/home/ CygwinRoot/home/(userName), 运行"cd /"后就可以理解了;
-
2 下载并安装make
- 2.1 从如下网址下载make的源码,https://ftp.gnu.org/gnu/make/,然后解压
- 2.2 打开Cygwin64 Terminal命令行,进入源码根目录,然后运行:configure && ./build.sh
- 2.3 编译得到了make.exe后将其移动到Cygwin的bin目录下
-
3 编译gmp
运行两个: ./configure 和 make install
./configure
Version: GNU MP 6.2.0
Host type: skylake-pc-cygwin
ABI: 64
Install prefix: /usr/local #说明会将库安装到该目录下,这和linux是很相似的
Compiler: gcc
Static libraries: yes
Shared libraries: no
编译结果(默认生成的是static的数据):
@nash-5 ~/mylibs/gmp-6.2.0
$ ls /usr/local/include/
gmp.h
@nash-5 ~/mylibs/gmp-6.2.0
$ ls /usr/local/lib/
libgmp.a libgmp.la pkgconfig
生成动态连接库(注意: 动态连接库和静态连接库的.h文件不同,所以注意分成2个文件夹,至少对于gmp是如此):
./configure --prefix=/home/chenxy/mylibs/gmp-6.2.0/build/shared --enable-shared --disable-static
- 4 编译mfpr(需要gmp的依赖,而且是动态连接库)
进入mfpr的根目录:
运行./configure:
checking for gmp.h... no
configure: error: gmp.h can't be found, or is unusable.
运行./configure --help
···
--with-gmp-include=DIR GMP include directory
--with-gmp-lib=DIR GMP lib directory
···
所以:
./configure --prefix=/home/chenxy/mylibs/mpfr-4.1.0/build \
--with-gmp-include=/home/chenxy/mylibs/gmp-6.2.0/build/shared/include \
--with-gmp-lib=/home/chenxy/mylibs/gmp-6.2.0/build/shared/lib
make install