gcc 6.2.0升級
阿新 • • 發佈:2018-10-05
.gz soft 多選 依賴庫 sites ase 代碼 bash 4.2 1.下載GCC(6.2.0版本)
yum install -y gcc
yum install -y gcc-c++
https://gcc.gnu.org/mirrors.html
wget http://ftp.tsukuba.wide.ad.jp/software/gcc/releases/gcc-6.2.0/gcc-6.2.0.tar.gz
wget http://ftp.gnu.org/gnu/gcc/gcc-6.2.0/gcc-6.2.0.tar.gz cd gcc-6.2.0
./contrib/download_prerequisites
cd .. update-alternatives --install /usr/bin/gcc gcc /usr/local/gcc/bin/gcc 40
#ln -s /usr/local/gcc/bin/gcc /usr/local/bin/cc (必須添加)
#ln -s /usr/local/gcc/bin/gcc /usr/local/bin/gcc (必須添加)
#ln -s /usr/local/gcc/bin/g++ /usr/local/bin/g++(必須添加) export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/gmp/lib:/usr/local/mpfr/lib:/usr/local/mpc/lib:/usr/local/gcc/lib
source /etc/profile
#export LD_LIBRARY_PATH
yum remove gcc -y
yum remove g++ -y
yum install -y gcc
yum install -y gcc-c++
https://gcc.gnu.org/mirrors.html
wget http://ftp.tsukuba.wide.ad.jp/software/gcc/releases/gcc-6.2.0/gcc-6.2.0.tar.gz
wget http://ftp.gnu.org/gnu/gcc/gcc-6.2.0/gcc-6.2.0.tar.gz
在下載的GCC中的./contrib/download_prerequisites中也能找到對應的以來下載地址(推薦此方法,因為對應的依賴是對應你的GCC版本的,不需要作過多選擇)。
2.下載編譯所需依賴庫
./contrib/download_prerequisites
cd ..
3.建立編譯輸出目錄
mkdir gcc-build-6.2.0
4.進入此目錄,執行以下命令,生成makefile文件
cd gcc-build-6.2.0
../gcc-6.2.0/configure --prefix=/usr/local/gcc --enable-checking=release --enable-languages=c,c++ --disable-multilib
5.編譯
make -j8
6.安裝
make install
5.檢查GCC版本
gcc -v
6、將新版本的gcc加入命令搜索路徑中:
#ln -s /usr/local/gcc/bin/gcc /usr/local/bin/cc (必須添加)
#ln -s /usr/local/gcc/bin/gcc /usr/local/bin/gcc (必須添加)
#ln -s /usr/local/gcc/bin/g++ /usr/local/bin/g++(必須添加)
7、添加環境變量:
vi /etc/bashrc
加入代碼:
添加如下代碼:
gcc
LD_LIBRARY_PATH=:/usr/local/mpc-0.8.1/lib:/usr/local/gmp-4.3.2/lib:/usr/local/mpfr-2.4.2/lib:/usr/local/gcc-4.6.1/lib
source /etc/profile
#export LD_LIBRARY_PATH
yum remove gcc -y
yum remove g++ -y
gcc 6.2.0升級