Summary:
When compiling the C++ code of the open source FunASR project, the required gcc version may not meet the requirements, and the gcc version needs to be upgraded. However, most of the ways to upgrade gcc from the Internet are through simple yum commands. I also tried this method , this method cannot be upgraded to the latest version. If you want to upgrade to the latest version, you need to download the source code yourself and upgrade through source code compilation.
1. Download related dependencies
gcc download address: http://ftp.gnu.org/gnu/gcc/?C=M;O=D
gcc domestic download address: https://mirrors.nju.edu.cn/gnu/gcc/gcc-11.4.0/
wget http://ftp.gnu.org/gnu/gcc/gcc-11.4.0/gcc-11.4.0.tar.gz # 这里下载的是gcc 11.4版本
./contrib/download_prerequisites # 执行这行命令会自动下载gcc相关依赖
# 下载完成依赖之后,解压
tar -xvf gmp-6.1.0.tar.bz2
tar -xvf mpfr-3.1.6.tar.bz2
tar -xvf mpc-1.0.3.tar.gz
tar -xvf isl-0.18.tar.bz2
2. Compile and install related dependencies
Note: make -j 4 in all the following commands refers to compiling with 4-core cpu, please set it according to the actual situation of your server.
At the same time, you also need to pay attention to the version of dependencies. Please fill in your own actual version.
Compile and install gmp
cd gmp-*
./configure -prefix=/usr/local/gmp-6.1.0
make -j 4
make install
Compile and install mpfr
cd mpfr-*
./configure -prefix=/usr/local/mpfr-4.1.0 --with-gmp=/usr/local/gmp-6.1.0
make -j 4
make install
Compile and install mpc
cd mpc-*
./configure -prefix=/usr/local/mpc-1.2.1 --with-gmp=/usr/local/gmp-6.1.0 --with-mpfr=/usr/local/mpfr-4.1.0
make -j 4
make install
Compile and install isl
cd isl-*
./configure --prefix=/usr/local/isl-0.18 --with-gmp=/usr/local/gmp-6.1.0
make -j 4
make install
**Supplementary note:** If you have not downloaded these dependencies, you can also run and download them in the following way.
wget http://ftp.gnu.org/gnu/gmp/gmp-6.1.0.tar.xz
wget http://ftp.gnu.org/gnu/mpc/mpc-1.0.3.tar.gz
wget http://ftp.gnu.org/gnu/mpfr/mpfr-3.1.4.tar.xz
wget http://isl.gforge.inria.fr/isl-0.18.tar.xz
3. Compile and install GCC
This process takes a long time, please be patient.
# 切换到解压出来的gcc目录里面
# 执行配置
./configure -prefix=/usr/local/gcc-11.4.0 --enable-threads=posix --disable-checking --disable-multilib --enable-languages=c,c++ --with-gmp=/usr/local/gmp-6.1.0 --with-mpfr=/usr/local/mpfr-3.1.6 --with-mpc=/usr/local/mpc-1.0.3
# 编译
make -j 4
# 安装
make install
reference documents
[1] Compile and install gcc-8.2.0 from source code under Centos7.5