Here I only shows manual upgrade of GCC to 4.8.1 (other higher versions are similar methods, GCC6 and GCC8 have been tested).
How to Upgrade GCC In Centos 6
Manual compilation and installation
Manually compile and upgrade GCC to 4.8.1
- Install Development Tools
yum groupinstall "Development Tools"
- Install glibc-devel.i686 (the 32-bit version is required to build GCC)
yum install glibc-devel.i686
- Download GCC 4.8.1
Compiling GCC requires a large enough space (5G or more),
Please make sure that there is enough free space on the disk
. I chooses to operate directly in the root directory.
cd /root
wget http://mirrors.nju.edu.cn/gnu/gcc/gcc-4.8.1/gcc-4.8.1.tar.bz2
- Unzip and compile and install
tar -jxvf gcc-4.8.1.tar.bz2
cd gcc-4.8.1
./contrib/download_prerequisites
cd ..
mkdir objdir
cd objdir
../gcc-4.8.1/configure --prefix=/usr
make -j4
make install
Using a third-party Repo library installation
SCL library
Using a third-party library SCL (software selection) of CentOS, SCL can install a new software package and coexist with the old software package without overwriting the original system software package and can use the scl command to switch, but there is also a disadvantage that only 64 is supported. Bit. Also devtoolset-4 (gcc 5.2) and previous versions have been supported, and can only be installed by other methods.
yum -y install centos-release-scl
yum -y install devtoolset-8-gcc devtoolset-8-gcc-c++ devtoolset-8-binutils
scl enable devtoolset-8 bash
Which version do you want to change the number 8 in the second command to the major version number you want? This upgrade to the latest version, such as 8 upgrade to 8.2.0 instead of 8.1.
Start gcc with the scl command. This is only temporary. When your shell is closed or restarted, the original version will be restored. To use the upgraded version all the time, you can use the following command:
echo "source /opt/rh/devtoolset-8/enable" >>/etc/profile
source /etc/profile