编译 GMP,MPFR,MPC
参考博客:https://zhuanlan.zhihu.com/p/627799889
2. 编译 GMP,MPFR,MPC
注意三个库编译的顺序 (gmp -> mpfr -> mpc)。因为编译 mpfr 时需要依赖于 gmp,编译mpc时候又需要依赖于 gmp 和 mpfr,所以需要最先编译 gmp,然后编译 mpfr,最后编译 mpc。编译过程中需要在 configure 配置时设置好 gmp,mpfr 的 include 和 lib 路径,不然就会遇见 configure: error: libgmp not found or uses a different ABI (including static vs shared). configure: error: libmpfr not found or uses a different ABI (including static vs shared). 这两个 configure: error。
2.1. 编译GMP 编译的时候需要记录下 --prefix 参数的值,也就是我们自定义的gmp的安装目录,后面编译其他两个库和gcc的时候需要使用。
tar -xvjf gmp-6.2.1.tar.bz2
cd gmp-6.2.1/
./configure --prefix=$(pwd)
make
make install
2.2. 编译MPFR
tar -xvjf mpfr-4.1.0.tar.bz2
cd mpfr-4.1.0/
./configure --prefix=$(pwd) \
--with-gmp-include=prefolder/gmp-6.2.1/include \
--with-gmp-lib=prefolder/gmp-6.2.1/lib \
make
make install
2.3. 编译MPC
tar -xvzf mpc-1.2.1.tar.gz
cd mpc-1.2.1/
./configure --prefix=$(pwd) \
--with-gmp-include=prefolder/gmp-6.2.1/include \
--with-gmp-lib=prefolder/gmp-6.2.1/lib \
--with-mpfr-include=prefolder/mpfr-4.1.0/include \
--with-mpfr-lib=prefolder/mpfr-4.1.0/lib \
make
make install