CentOS6.6 Compiling and installing GCC-5.2.0
Linux C + + programs written under the natural lack of a good compiler, Linux under the more common nature is gcc.
In 2015, GCC also had a 5.2.0 version, and there was better support for C++11/14.
So, today we're going to talk about the installation of the GCC build, which is the latest 5.2.0.
Let's get to the point (the whole process is recommended as root):
1. Download the GCC source code:
wget ftp://mirrors.kernel.org/gnu/gcc/gcc-5.2.0/gcc-5.2.0.tar.gz
2. Unzip:
TAR-ZXVF gcc-5.2.0.tar.gz
3. Download the required dependencies for compilation:
CD gcc-5.2.0//The GCC folder after unpacking
./contrib/download_prerequisites//download dependencies
Cd.. Return to upper level directory
4. Build the compiled output directory:
mkdir gcc-build-5.2.0
5. Go to the output directory, execute the following command, and generate the makefile file:
CD gcc-build-5.2.0
.. /gcc-5.2.0/configure--enable-checking=release--enable-languages=c,c++--disable-multilib
6. Compiling:
Make-j4
The next step is to wait, and the whole process is about 40 minutes.
PS: It is best not to do anything else during the compilation process, the entire process CPU is full,
If the inexplicable end, there are a lot of trouble back. Remember that at compile time the current directory has a minimum remaining space of more than 4G, or it will fail to compile
7. Installation:
After the compilation is complete, we can perform the installation:
Make install
8. Check the version:
GCC--version
or gcc-v
7. Switch GCC to the new version to determine the path of the newly installed GCC, usually by default under/usr/local/bin.
Can updatedb first, then locate gcc-4.8|tail look for Ls/usr/local/bin | grep GCC adds new gcc to optional,
The last third is the name, the penultimate parameter is the new GCC path, the final parameter 40 is the priority, and the new version is automatically used after a larger set.
Update-alternatives--INSTALL/USR/BIN/GCC x86_64-unknown-linux-gnu-gcc-5.2.0/usr/local/bin/x86_64- unknown-linux-gnu-gcc-5.2.0 40
After that, you need to remove the GCC file from the usr/bin/directory or avoid accidental occurrences, and you can name it gcc.bak.
Here is a description of the USR/BIN/GCC that you have been using when viewing the current version with Gcc-v.
The purpose of Ln-s/USR/LOCAL/BIN/X86_64-UNKNOWN-LINUX-GNU-GCC-5.2.0/USR/BIN/GCC is to generate GCC version 5.2.
The complete operation of this step is as follows:
Mv/usr/bin/gcc/usr/bin/gcc.bak
Ln-s/USR/LOCAL/BIN/X86_64-UNKNOWN-LINUX-GNU-GCC-5.2.0/USR/BIN/GCC
8. Confirm that the current version has been switched to the new GCC-V I am here with ssh remote, found that the version has not changed, disconnected re-training, the regeneration session after the discovery became 5.2!
===========================================================================================
Refer to the following articles and test your own steps to refine them
Http://www.linuxidc.com/Linux/2015-05/116996.htm
Http://www.2cto.com/os/201505/396648.html
Http://www.linuxidc.com/Linux/2015-05/116996.htm
Http://bbs.kafan.cn/thread-1757522-1-1.html
This article from "Flying Pig Ah ~~~~~" blog, declined reprint!
CentOS6.6 Compiling and installing GCC-5.2.0