Upgrade Prerequisites
Source compilation requires at least one GCC compiler to be available.
You can use Yum to automatically install or manually download RPM package installation.
With Yum you can see that at least the following packages are required, so you can search the RPM package site to download the appropriate RPM packages, but the version is right, the Yum version is for 4.4.7. So what version of GCC is needed to find out which version corresponds to the dependent package. Now the RPM site will explain which packages this package depends on, which packages are dependent on, very convenient, but it is more time-consuming to find.
Compiling and installing GCC4.8.2
Download gcc4.8.2 Source Package
1 FTP://ftp.gnu.org/gnu/gcc/gcc-4.8.2/gcc-4.8.2.tar.gz;
The first thing you need to do is download the MPC,MPFR,GMP package that the GCC installation relies on, and GCC comes with a script to help us download and build a good link, and so on, you can download the dependency package yourself.
1 Tar gcc-4.8. 2. Tar . GZ 2 gcc-4.8. 2 3 ./contrib/download_prerequisites
Open the above download_prerequisites can see, it first downloaded 3 packages, so when found that the script card in the download place may be inaccessible reason, it is necessary to find a new, the method is very simple, Google filename can be found a lot.
Start compiling GCC
mkdir gcc-build-4.8. 2 gcc-build-4.8. 2 .. /configure-enable-checking=release-enable-languages=c,c++-disable-multilibmake make Install
After the installation is complete, if you find that the GCC-V version has not changed, then execute the following startup script.
1 source/etc/profile2 source ~/.bash_profile
Problems after installation
After installation, although the GCC g++ C + + and other versions have been updated to 4.8.2 but in fact there are at least two versions of GCC in the computer
Whereis or where you can see that there are multiple GCC files, the which command can see that the command gcc corresponds to USR/LOCAL/BIN/GCC, and the original GCC execution file is in/USR/BIN/GCC, execute/USR/BIN/GCC- V can see the GCC version or 4.4, although this is not a problem, but some shell scripts or makefile directly written in GCC's absolute path, it is likely to use the old version of the GCC to compile, resulting in failure. So you still need to overwrite the original GCC. The first way to think is to USR/BIN/GCC, soft links to USR/LOCAL/BIN/GCC, for g++,c++ and so also do similar treatment
This approach seems to solve the problem, but always feel that it is not reliable, until recently compiled Apache thrift found still not quite right. So consider whether the installation path can be specified when GCC is installed.
Perform
1
You can see that there are really such options.
So just take the--prefix=/usr with you in configure and install gcc into usr.
CentOS6.6 source code compilation upgrade GCC to 4.8.2