Linux系统自带GCC源中gcc版本太低,推荐手动安装gcc8.3.0
手动安装gcc8.3.0之前需要先确保安装gcc环境依赖GMP 4.2+ 、 MPFR 2.3.1+ 、 MPC 0.8.0+,否则会报出以下错误
configure: error: Building GCC requires GMP 4.2+, MPFR 2.3.1+ and MPC 0.8.0+.
Try the --with-gmp, --with-mpfr and/or --with-mpc options to specify their locations.
如果报错:
error while loading shared libraries: libmpfr.so.6: cannot open shared object file:
No such file or directory
解决方案参考:
参考1
参考2
我们在mpfr4.0.2已经下了动态库,在 /usr/local/mpfr-4.0.2 路径下的lib文件夹中。
将这里面的 libmpfr.so.6.0.2 移动到 /usr/lib 下。
vi /etc/ld.so.conf #添加库的路径include /usr/local/lib/
然后终端命令行执行ldconfig,再重新编译。
安装GMP 6.1.2
注:有时候没有权限需要手动下载时,直接复制wget后的链接在浏览器打开即可
下载GMP安装包
wget http://mirror.hust.edu.cn/gnu/gmp/gmp-6.1.2.tar.xz
解压GMP安装包
tar -Jxf gmp