Installing GCC
The built-in GCC software on CentOS 7.6 is too early. Upgrade GCC to 5.3.0 or later. The GCC version is 7.3.0 on openEuler 20.03 and 10.3.1 on openEuler 22.03. Therefore, you do not need to upgrade them. As an example, the following procedure describes how to upgrade GCC to 7.3.0 on CentOS 7.6.
To upgrade GCC to 7.3.0 on CentOS 7.6, perform the following steps:
- Download GCC 7.3.0.
1 2
cd /home wget https://mirrors.tuna.tsinghua.edu.cn/gnu/gcc/gcc-7.3.0/gcc-7.3.0.tar.gz --no-check-certificate
- Decompress the GCC source package.
1tar -xvf gcc-7.3.0.tar.gz

- Compile and install GCC.
- Go to the GCC file path and set GCC parameters.
1 2
cd /home/gcc-7.3.0 ./configure --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --enable-bootstrap

- --prefix=PATH: specifies the GCC installation directory. The default directory is /usr.
- --mandir=PATH: specifies the directory for storing GCC files. The default directory is /usr/share/man.
- --infodir=PATH: specifies the directory for storing GCC logs. The default directory is /usr/share/info.
- --enable-bootstrap: enables bootstrap installation.
If the error message "configure: error: no acceptable C compiler found in $PATH" is reported, run the following command:
1yum -y reinstall gcc gcc-c++
- Compile the GCC source code.
1make -j 96
In the command, -j 96 can make full use of the multi-core feature of the CPUs to accelerate the compilation. The number following -j indicates the number of CPU cores. You can run the cat /proc/cpuinfo | grep processor | wc -l command to query the number of CPU cores. The value specified must be less than or equal to the actual number of CPU cores.

- Install GCC.
1make -j 96 install
- Go to the GCC file path and set GCC parameters.
- Check the GCC version.
1gcc -vThe GCC version has been upgraded to 7.3.0.
