1. 程式人生 > >CentOS 7安裝GCC 8.2 實錄

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

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                     #匯出驗證