Skip to main content

Home

Installing GNU Compiler Collection (GCC)

Notice

GCC compiler version 4.9.3 must be installed.

  1. Check if you have already installed GCC.

    [unravel@host ~]$ which gcc
    /bin/gcc
    /bin/gcc
    [unravel@host ~]$ /bin/gcc --version
  2. Install or update to the latest GCC version if not done already.

    Ensure to install from the Software Collections (SCL) repository. The SCL is available on CentOS 6.5. SCL repositories provide a package named Developer Toolset, which includes newer versions of the GNU Compiler Collection and other development and debugging tools.

  3. Set up the SCL, run the following:

    # On CentOS 7 and later
    [unravel@host ~]$ sudo yum install -y centos-release-scl
    
    # On CentOS 6.X
    [unravel@host ~]$ sudo yum install -y centos-release-SCL
  4. Install Developer Toolset.

    There are different versions of Developer Toolset collections available. The minimum requirement is devtoolset-8.

    [unravel@host ~]$ sudo yum install -y devtoolset-8
  5. Access the new GCC version 8:

    [unravel@host ~]$ scl enable devtoolset-8 bash
    
    # C compiler
    [unravel@host ~]$ gcc --version
    
    # C++ compiler
    [unravel@host ~]$ g++ --version
    # C compiler
    gcc (GCC) 8.3.1 20190311 (Red Hat 8.3.1-3)
    Copyright (C) 2018 Free Software Foundation, Inc.
    This is free software; see the source for copying conditions.  There is NO
    warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
    
    # C++ compiler
    g++ (GCC) 8.3.1 20190311 (Red Hat 8.3.1-3)
    Copyright (C) 2018 Free Software Foundation, Inc.
    This is free software; see the source for copying conditions.  There is NO
    warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  6. Permanently enable an SCL or persist it after a reboot/logout.

    • Add the following in the unravel user’s bash_profile or bashrc:

      [unravel@host ~]$ su - unravel
      [unravel@host ~]$ echo 'source scl_source enable devtoolset-8' >> ~/.bashrc
    • If scl_source does not work, update scl-utils.

      yum update scl-utils 
    • If you still face issues, add /opt/rh/devtoolset-8/enable to the unravel user's bash_profile or bashrc:

      Caution

      This is NOT a recommended method and can be implemented only as a last option.

      [unravel@host ~]$ echo 'source /opt/rh/devtoolset-8/enable' >> ~/.bashrc
  7. Verify the GCC version after adding in bash_profile or bashrc:

    # C compiler
    [unravel@host ~]$ gcc --version
    
    
    # C++ compiler
    [unravel@host ~]$ g++ --version
    # C compiler
    gcc (GCC) 8.3.1 20190311 (Red Hat 8.3.1-3)
    Copyright (C) 2018 Free Software Foundation, Inc.
    This is free software; see the source for copying conditions.  There is NO
    warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
    
    # C++ compiler
    g++ (GCC) 8.3.1 20190311 (Red Hat 8.3.1-3)
    Copyright (C) 2018 Free Software Foundation, Inc.
    This is free software; see the source for copying conditions.  There is NO
    warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.