安装最新版本的GCC编译器(./configure执行编译报错 C++ compiler too old)

源码编译
1258
linux
linux 举报
2022-02-16
手动获取新版本的GCC

GNU GCC 获取GCC源码

编译安装过程较长,防止ssh连接中断建议使用screen

解压GCC

tar -xvf gcc-9.2.0.tar.gz

执行configure报错

configure: error: Building GCC requires GMP 4.2+, MPFR 2.4.0+ and MPC 0.8.0+.
Try the --with-gmp, --with-mpfr and/or --with-mpc options to specify
their locations.  Source code for these libraries can be found at
their respective hosting sites as well as at
ftp://gcc.gnu.org/pub/gcc/infrastructure/.  See also
http://gcc.gnu.org/install/prerequisites.html for additional info.  If
you obtained GMP, MPFR and/or MPC from a vendor distribution package,
make sure that you have installed both the libraries and the header
files.  They may be located in separate packages.

Building GCC requires GMP 4.2+, MPFR 2.4.0+ and MPC 0.8.0+.

需要安装GMP MPFR MPC

MPC : ftp://ftp.gnu.org/gnu/mpc/mpc-1.1.0.tar.gz

GMP : ftp://ftp.gnu.org/gnu/gmp/gmp-6.1.2.tar.xz

MPFR : http://ftp.gnu.org/gnu/mpfr/mpfr-4.0.2.tar.gz

这里提供了几个最新版本的下载地址

编译安装GMP

创建一个临时目录temp并在temp下进行编译和安装

$tar -xvf gmp-6.1.2.tar.xz
$mkdir temp
$cd temp
$sudo ../gmp-6.1.2/configure --prefix=/usr/local/gmp-6.1.2

configure: summary of build options:

  Version:           GNU MP 6.1.2
  Host type:         haswell-pc-linux-gnu
  ABI:               64
  Install prefix:    /usr/local/gmp-6.1.2
  Compiler:          gcc -std=gnu99
  Static libraries:  yes
  Shared libraries:  yes
  
$sudo make
$sudo make install
编译安装MPFR
tar -xvf mpfr-4.0.2.tar.gz
cd mpfr-4.0.2.tar.gz
mkdir temp
cd temp
sudo ../configure --prefix=/usr/local/mpfr-4.0.2 --with-gmp=/usr/local/gmp-6.1.2
sudo make
sudo make check
sudo make install

指定gmp版本路径

--with-gmp=/user/gmp-6.1.0/gmp-6.1.0-obj
安装MPC
tar -zxvf mpc-1.1.0.tar.gz
cd mpc-1.1.0/
mkdir temp
cd temp
sudo ../configure --prefix=/usr/local/mpc-1.1.0 --with-gmp=/usr/local/gmp-6.1.2 --with-mpfr=/usr/local/mpfr-4.0.2
sudo make
sudo make check
sudo make install
添加ld.so.conf
sudo vim /etc/ld.so.conf

添加

/usr/local/gmp-6.1.2/lib
/usr/local/mpfr-4.0.2/lib
/usr/local/mpc-1.1.0/lib

添加完成后保存执行

sudo ldconfig
安装GCC

由于之前解压过GCC,如果没有解压可以执行tar

tar -xvf gcc-9.2.0.tar.gz

更改参数

sudo ../configure --prefix=/usr/local/gcc-9.2.0 --enable-threads=posix --disable-checking --enable--long-long --with-gmp=/usr/local/gmp-6.1.2 --with-mpfr=/usr/local/mpfr-4.0.2 --with-mpc=/usr/local/mpc-1.1.0 --with-isl=/usr/local/isl-0.18 --disable-multilib

终于创建makefile了


倒序看帖 只看楼主
热点关注
/lib/ld-linux.so.2: bad ELF interpreter: No such file or directory
服务停止、启动、重启一体化脚本,万能语言启动脚本
shell参数判断
在后台用进程名运行bash脚本
shell脚本每行后面多了一个^M的原因和解决办法
定时检测服务,检测down掉后重启。系统检测到DMSERVER运行正常
挂载磁盘的时候遇到一个问题,挂载完磁盘之后重启服务器挂载的盘丢失了.
中标麒麟系统Your trial is EXPIRED and no VALID licens
termux 开启ssh并用用户名和密码登陆
组成共享库的目标文件和一般的目标文件有所不同,在编译时要加-fPIC和-share选项,例如:
gcc指定链接库路径后还是找不到库文件
./configure -build,-host,-target设置
shell脚本每行后面多了一个^M的原因和解决办法
shell 中 if [ “x${var}“ == “x“ ] 中 x的作用
查看linux机器是32位还是64位的方法