Ask Your Question

Revision history [back]

Assuming you want to upgrade the GCC (GNU Compiler Collection) on CentOS 7 to version 4.9.4, here are the steps:

  1. Enable the Software Collections (SCL) repository:

    sudo yum install centos-release-scl
    
  2. Install the devtoolset-3 package, which includes GCC 4.9:

    sudo yum install devtoolset-3
    
  3. Enable the devtoolset-3 environment by running:

    scl enable devtoolset-3 bash
    

    This will set up the environment variables necessary to use GCC 4.9.

  4. Verify that GCC 4.9 is being used:

    gcc --version
    

    You should see output similar to:

    gcc (GCC) 4.9.2 20150212 (Red Hat 4.9.2-6)
    

    Note that the version number may be slightly different depending on updates.

If you want to make this version of GCC available system-wide without having to enable the devtoolset-3 environment each time, you can create a script to set up the environment variables and add it to your system's shell initialization script. For example, you could create a file called scl_enable.sh with the following contents:

#!/bin/bash
source scl_source enable devtoolset-3

Then add this line to your .bashrc file:

source /path/to/scl_enable.sh

Replace /path/to with the actual path to the scl_enable.sh file. This will automatically enable the devtoolset-3 environment every time you open a new shell session.