进入网址下载所需要的gcc版本文件
网址为:https://mirrors.kernel.org/gnu/gcc/
wget https://mirrors.kernel.org/gnu/gcc/gcc-8.5.0/gcc-8.5.0.tar.gz
解压并安装
tar -xzvf gcc-8.5.0.tar.gz
cd gcc-8.5.0
./contrib/download_prerequisites
../gcc-8.5.0/configure --disable-checking --enable-languages=c,c++,fortran --disable-multilib --prefix=path --enable-threads=posix
修改bashrc
export PATH=path/bin:$PATH
export LD_LIBRARY_PATH=path/lib/:/path/lib64:$LD_LIBRARY_PATH
激活并查看新的版本
source ~/.bashrc
gcc -v
成功安装
参考:https://blog.csdn.net/weixin_42054508/article/details/106468768