Centos7 离线安装 gcc-8.4.0

http://ftp.gnu.org/gnu/gcc/

 tar -zxvf gcc-8.4.0.tar.gz
  • 下载依赖
yum -y install bzip2 zlib zlib-devel
yum -y install gcc gcc-c++ gdb

将文件 ./contrib/download_prerequisites 中的地址:

ftp://gcc.gnu.org/pub/gcc/infrastructure/

替换为:

http://www.mirrorservice.org/sites/sourceware.org/pub/gcc/infrastructure/

然后执行下载依赖:

cd gcc-8.4.0
chmod +x /opt/gcc-8.4.0/contrib/download_prerequisites
./contrib/download_prerequisites
  • 新建编译目录
mkdir build
cd build
  • 配置参数
/opt/gcc-8.4.0/configure --prefix=/usr/local/gcc-8.4.0 --enable-threads=posix --disable-checking --disable-multilib --enable--long-long --with-system-zlib --enable-languages=c,c++
  • 编译安装
make -j8
make install
  • 配置默认为 gcc-8.4.0
ln -snf /usr/local/gcc-8.4.0/bin/gcc /usr/bin/gcc
ln -snf /usr/local/gcc-8.4.0/bin/g++ /usr/bin/g++
  • 查看版本
gcc --version
g++ --version
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容