How Do I Install GCC 7.3.0?

Perform the following steps as the root user.

  1. Click here to download gcc-7.3.0.tar.gz.
  2. GCC installation requires adequate temporary space. Run the following command to clear the /tmp directory in advance:
    rm -rf /tmp/*
  3. Install dependencies.

    For CentOS/BCLinux, run the following command:

    yum install bzip2    

    For Ubuntu/Debian, run the following command:

    apt-get install bzip2    
  4. Build and install GCC.
    1. Go to the directory where the source package gcc-7.3.0.tar.gz is located and run the following command to decompress it:
      tar -zxvf gcc-7.3.0.tar.gz
    2. Run the following commands to go to the extracted directory and download the GCC dependency packages:
      cd gcc-7.3.0
      ./contrib/download_prerequisites

      If an error is reported during the command execution, run the following commands in the gcc-7.3.0/ directory to download the dependency packages:

      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 validation fails, check whether the dependency packages are downloaded more than once.

    3. Run the following commands for configuration, build, and installation.
      ./configure --enable-languages=c,c++ --disable-multilib --with-system-zlib --prefix=/usr/local/linux_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 option is used to specify the linux_gcc7.3.0 installation path, which is configurable. Do not set it to /usr/local or /usr, which is the default installation path for the GCC installed by using the software source. Otherwise, a conflict occurs and the original GCC compilation environment of the system is damaged. In this example, the installation path is set to /usr/local/linux_gcc7.3.0.

  5. Set the environment variable.

    Training must be performed in the compilation environment with GCC upgraded. If you will run training, configure the following environment variable in your training script:

    export LD_LIBRARY_PATH=${install_path}/lib64:${LD_LIBRARY_PATH}

    ${install_path} indicates the GCC 7.3.0 installation path configured in 4.c. In this example, the installation path is /usr/local/gcc7.3.0/.

    Skip this step if you do not need to use the compilation environment with GCC upgraded.