源码编译
1.查看当前gcc版本
# gcc --version
gcc (GCC) 4.8.5 20150623 (Red Hat 4.8.5-44)
Copyright (C) 2015 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
2.安装默认的开发工具
# yum groupinstall "Development Tools"
3.获取安装包并解压
# cd /usr/local/src/ # wget http://ftp.gnu.org/gnu/gcc/gcc-7.3.0/gcc-7.3.0.tar.xz # tar xvf gcc-7.3.0.tar.xz
4.安装依赖软件
# cd gcc-7.3.0/ # ./contrib/download_prerequisites ./contrib/download_prerequisites会帮我们下载、配置、安装依赖库,节约我们的时间和精力
5.生成Makefile文件
# ./configure -enable-checking=release -enable-languages=c,c++ -disable-multilib
6.编译
# make -j4 多核主机可以添加-j4,此步骤非常耗时
7.安装
make install
8.配置
# cd /usr/lib64 # cp /usr/local/src/gcc-7.3.0/stage1-x86_64-pc-linux-gnu/libstdc++-v3/src/.libs/libstdc++.so.6.0.24 . # mv libstdc++.so.6 libstdc++.so.6.old # ln -sv libstdc++.so.6.0.22 libstdc++.so.6
9.查看升级后的gcc版本
# gcc --version
yum安装
yum install -y http://mirror.centos.org/centos/7/extras/x86_64/Packages/centos-release-scl-2-3.el7.centos.noarch.rpm yum install devtoolset-9-gcc-c++ 临时生效: scl enable devtoolset-9 bash 或者source /opt/rh/devtoolset-9/enable 永久生效: echo "source /opt/rh/devtoolset-9/enable" >>/etc/profile
推荐yum安装,方便快捷。
标签:gcc,enable,libstd,c++,升级,7.3,so.6,Linux From: https://www.cnblogs.com/zhanggaofeng/p/17406774.html