Installing GCC 7.3.0
Perform the following steps as the root user:
- Download gcc-7.3.0.tar.gz from https://mirrors.tuna.tsinghua.edu.cn/gnu/gcc/gcc-7.3.0/gcc-7.3.0.tar.gz.
- The GCC installation occupies a large amount of temporary space. Therefore, run the following command to clear the /tmp directory:
rm -rf /tmp/*
- Install the dependency package. (CentOS and Ubuntu are used as examples.)
- For CentOS, run the following command:
yum install bzip2
- For Ubuntu, run the following command:
apt-get install bzip2
- For CentOS, run the following command:
- Compile and install GCC.
- Go to the directory where the gcc-7.3.0.tar.gz source code package is located and run the following command to decompress the source code package:
tar -zxvf gcc-7.3.0.tar.gz
- Go to the decompressed folder and download the GCC dependencies:
cd gcc-7.3.0 ./contrib/download_prerequisites
If an error is reported during the execution of the preceding command, run the following commands to download the dependencies from the gcc-7.3.0/ folder:
wget http://gcc.gnu.org/pub/gcc/infrastructure/gmp-6.1.0.tar.bz2 wget http://gcc.gnu.org/pub/gcc/infrastructure/mpfr-3.1.4.tar.bz2 wget http://gcc.gnu.org/pub/gcc/infrastructure/mpc-1.0.3.tar.gz wget http://gcc.gnu.org/pub/gcc/infrastructure/isl-0.16.1.tar.bz2
After the preceding dependencies are downloaded, run the following command again:
./contrib/download_prerequisites
If the preceding command fails, ensure that the dependencies are successfully downloaded at a time and no repeated download occurs.
- Run the configuration, compilation, and installation commands.
./configure --enable-languages=c,c++ --disable-multilib --with-system-zlib --prefix=/usr/local/gcc7.3.0 make -j15 # Check the number of CPUs by running grep -w processor /proc/cpuinfo|wc -l. In this example, the number is 15. You can set the parameters as required. make install
The --prefix parameter is used to specify the GCC 7.3.0 installation path. You can set it as required. However, do not set it to /usr/local or /usr because they conflict with the GCC that is installed by default by the system using the software source. Otherwise, the original GCC compilation environment of the system will be damaged. In this example, use /usr/local/gcc7.3.0.
- Go to the directory where the gcc-7.3.0.tar.gz source code package is located and run the following command to decompress the source code package:
- Configure environment variables as required.
To use the GCC 7.3.0 compilation environment, configure the following environment variables.
For example, before starting the online inference or training process, run the following command to configure environment variables:
export LD_LIBRARY_PATH=/usr/local/gcc7.3.0/lib64:${LD_LIBRARY_PATH} export PATH=/usr/local/gcc7.3.0/bin:${PATH}In the preceding command, /usr/local/gcc7.3.0 indicates the GCC 7.3.0 installation path configured in 4.c. Replace it with the actual path.