How to Install the Latest GCC 13.2.0 on CentOS 7.9

Are you looking to upgrade your compiler toolkit on CentOS 7.9 with the latest GCC 13.2.0? Here’s a comprehensive guide to walk you through the installation process. Let’s boost your system’s capabilities with the newest features and optimizations that GCC 13.2.0 has to offer! 🚀

Prerequisites:

  • A CentOS 7.9 system
  • Sudo privileges

🔨 Installation Steps:

  1. Install Dependencies:
    • Ensure your system is up-to-date and equipped with all the necessary development tools:
      sudo yum update -y
      sudo yum groupinstall -y "Development Tools"
      sudo yum install -y gcc gcc-c++ make bzip2 tar glibc-devel glibc-static libstdc++-static libstdc++-devel libgcc libgomp kernel-headers kernel-devel perl-Data-Dumper perl-Thread-Queue python3
      
  2. Download GCC Source Code:
    • Grab the latest GCC source code from the official GNU site:
      wget https://ftp.gnu.org/gnu/gcc/gcc-13.2.0/gcc-13.2.0.tar.gz
  3. Extract Source Code:
    • Unpack the source code and move into the directory:
      tar -xf gcc-13.2.0.tar.gz
      cd gcc-13.2.0
  4. Preparation:
    • Get additional prerequisites needed by GCC:
      ./contrib/download_prerequisites
  5. Create a Build Directory:
    • It’s recommended to compile GCC outside of the source directory:
      cd ..
      mkdir gcc-build
      cd gcc-build
  6. Configure the Build Environment:
    • Set the configuration for the build:
      ../gcc-13.2.0/configure --prefix=/usr/local/gcc-13.2.0 --enable-languages=c,c++ --disable-multilib --disable-bootstrap --with-system-zlib
  7. Compile GCC:
    • Start the compilation process using all available cores:
      make -j$(nproc)
  8. Install GCC:
    • Once compilation is complete, install the new GCC version:
      sudo make install
  9. Update Environment Variables:
    • Add the new GCC binary to your PATH for easy access:
      echo $PATH
      export PATH=/usr/local/gcc-13.2.0/bin:$PATH
      export LD_LIBRARY_PATH=/usr/local/gcc-13.2.0/lib64:$LD_LIBRARY_PATH
      sudo ln -sf /usr/local/gcc-13.2.0/bin/gcc /usr/bin/gcc
      sudo ln -sf /usr/local/gcc-13.2.0/bin/g++ /usr/bin/g++
      source ~/.bashrc
      source ~/.bash_profile
    • Consider adding these lines to ~/.bashrc or ~/.bash_profile.
  10. Verify Installation:
    • Ensure the new GCC version is correctly installed:
      gcc --version
      /usr/local/gcc-13.2.0/bin/gcc --version

🥳 Congratulations! You’ve successfully installed GCC 13.2.0 on CentOS 7.9. Enjoy the cutting-edge functionalities of your updated compiler!

Scroll to Top