Centos7自带的gcc是4.8.5的,因为装软件需要,升级到新版的gcc
安装编译gcc
#下载地址:https://github.com/gcc-mirror/gcc
# https://gitee.com/mirrors/gcc.git
git clone -b releases/gcc-10.2.0 https://gitee.com/mirrors/gcc.git
cd gcc/
#gcc依赖了mpfr、gmp、mpc 和isl共四个库,所以需要安装
./contrib/download_prerequisites
./configure --prefix=/usr/local/gcc-10.2.0 --enable-bootstrap --enable-checking=release --enable-languages=c,c++ --disable-multilib
make -j `grep 'processor' /proc/cpuinfo | wc -l` && make install && make install
#可以做PATH
echo -e '\nexport PATH=/usr/local/gcc/bin:$PATH\n' >> /etc/profile.d/gcc.sh && source /etc/profile.d/gcc.sh
#也可以直接ln -sf /usr/local/gcc/bin /usr/bin/.
ln -sf /usr/bin/gcc /usr/bin/cc
ln -sf /usr/local/gcc-10.2.0 /usr/local/gcc
ln -sf /usr/local/gcc/include /usr/include/gcc
cat > /etc/ld.so.conf.d/gcc.conf<<EOF
/usr/local/gcc/lib64
EOF
ldconfig -v
ldconfig -p |grep gcc