Compile and install GCC under CentOS6.8
For the GCC installation of the default version through yum in CentOS, CentOS 5 is 4.1.2, CentOS 6 is 4.4.7, and CentOS 7 is 4.8.3.
Most of the time, compiling and installing software requires a later version of GCC. Otherwise, an error is reported.
So how to upgrade the GCC version?
First, check the GCC version number.
Currently, the latest version of GCC has reached 5.2, while CentOS 7 still uses 4.8. Therefore, based on compatibility considerations, I chose to upgrade to 4.8.5.
GCC Website: https://gcc.gnu.org
Next, we will start to compile and install GCC 4.8.5. Note that, before compiling and installing GCC, the system must first install the GCC and dependent libraries of the old version through yum.
If it is compiled in the x86_64 system, you also need to install libgcc. i686 glibc-devel.i686.
yuminstall-ygcctexinfo-texflexziplibgcc.i686glibc-devel.i686
Note: The GCC memory for compilation and installation is not less than 1 GB, the Swap is not less than 1 GB, and the hard disk is not less than 10 GB. Otherwise, an error may be reported and exited.
After the compilation and installation are complete, the directory gcc-4.8.5 will have as much as 5 GB.
1. Download source code
wgetftp://ftp.gnu.org/gnu/gcc/gcc-4.8.5/gcc-4.8.5.tar.gz
2. Download the dependency package
The compilation and installation of GCC must depend on the MCM, mpfr, and gmp packages. Fortunately, the built-in scripts in the GCC source code can easily download dependency packages.
tarzxfgcc-4.8.5.tar.gzcdgcc-4.8.5./contrib/download_prerequisites
Compile and install
# Cd gcc-4.8.1
#./Gcc-4.8.1/configure -- prefix =/usr/local/gcc-4.8.1 -- enable-languages ages = c, c +
Prefix =/usr/local/gcc-4.8.1 indicates the path for configuring the installation. If you do not specify the installation path, the execution file is placed under/usr/local/bin by default to facilitate maintenance, you can directly Delete this directory when you need to uninstall it.
Enable-languages ages indicates the installation language. Here, it indicates that only c and c ++ are installed.
Compile
After the preparation is complete, you can compile
# Make
This process takes about 2 hours. If an error is reported midway through, the system prompts fatal error: gnu/stubs-32, No such file or directory, as shown in:
Run the following command and re-compile
# Yum-y install glibc-devel.i686 -- setopt = protected_multilib = false
# Make
References:
Upgrade g ++ in CentOS 6.7
Https://allen-kevin.github.io/2016/09/28/CentOS%206.7%E4%B8%8B%E5%8D%87%E7%BA%A7g++/
Solve the libc. so.6: version 'glibc _ 100' not found Problem
Http://blog.csdn.net/cpplang/article/details/8462768
Install gcc4.8.5
Https://teddysun.com/432.html