CentOS 7安装GCC 8.2 实录

#!/bin/bash

yum -y install bzip2 gcc gcc-c++ glibc-headers

wget -c -P /opt/tmp/ wget https://mirrors.tuna.tsinghua.edu.cn/gnu/gcc/gcc-8.2.0/gcc-8.2.0.tar.gz

cd /opt/tmp/

tar zxvf gcc-8.2.0.tar.gz

cd gcc-8.2.0

./contrib/download_prerequisites                     #下载gmp mpfr mpc

cd ../    

mkdir build-gcc-8.2                     #不能在source目录下configure必须在上一层的目录下

cd build-gcc-8.2

../gcc-8.2.0/configure --prefix=/usr/local/gcc --enable-bootstrap --enable-checking=release --enable-languages=c,c++ --disable-multilib

扫描二维码关注公众号,回复: 4082405 查看本文章

make -j N

make install

#配置环境变量

gcc -v                     #查看当前gcc版本

echo -e '\nexport PATH=/usr/local/gcc/bin:$PATH\n' >> /etc/profile.d/gcc.sh && source /etc/profile.d/gcc.sh

#导出头文件

ln -sv /usr/local/gcc/include/ /usr/include/gcc

#导出库文件

vim /etc/ld.so.conf.d/gcc.conf

/usr/local/gcc/lib64                             #64位系统

ldconfig -v                     #配置生效

ldconfig -p |grep gcc                     #导出验证


猜你喜欢

转载自blog.51cto.com/1550349/2317242