1. Download gcc (6.2.0 version)
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
It can also be found in the./contrib/download_prerequisites in the downloaded GCC (this method is recommended because the corresponding dependency is corresponding to your GCC version and does not require too much choice).
2. Download the required libraries for compilation
CD gcc-6.2.0
./contrib/download_prerequisites
Cd..
3. Build the compiled output directory
mkdir gcc-build-6.2.0
4. Enter this directory and execute the following command to generate the makefile file
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. Compiling
Make-j8
6. Installation
Make install
5. Check the GCC version
Gcc-v
6. Add a new version of GCC to the command search path:
Update-alternatives--INSTALL/USR/BIN/GCC GCC/USR/LOCAL/GCC/BIN/GCC 40
#ln-S/USR/LOCAL/GCC/BIN/GCC/USR/LOCAL/BIN/CC (must be added)
#ln-S/USR/LOCAL/GCC/BIN/GCC/USR/LOCAL/BIN/GCC (must be added)
#ln-S/usr/local/gcc/bin/g++/usr/local/bin/g++ (must be added)
7. Add Environment variables:
Vi/etc/bashrc
Add code:
Add the following code:
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
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
GCC 6.2.0 Upgrade