Install latest GCC from source on Centos Linux release

When you have to upgrade gcc to build some application.

*Update Tested for gcc 9.2.0 version

Following are the steps documented for upgrading gcc on centos 7

Let’s update the box

Now that the update is done lets install the dependencies needed for the build.This is important you don’t want to wait to find one of the build dependencies were missing after 2hr’s of build

Looks like the gcc is really old version

Lets start the upgrade part

Next we will download the tar file from gcc mirror gcc-8.2.0.tar.gz from official mirror page http://gcc.gnu.org/mirrors.html and http://mirrors-usa.go-parts.com/gcc/releases/gcc-8.2.0/ . Choose different location based on your geo location.

In future the release numbers will differ but overall steps should be same

Untar the file

Create a separate build folder for our work, we should not mess up with the source code

Give configuration options more details can be found here https://gcc.gnu.org/install/configure.html.

Be sure that you have enough free diskspace in /tmp. Free /tmp folder before make .Start the make,this may take a while.Adjust -j number to available cpu cores. Be careful this step takes time ,run it in background if possible.

Finally install ,default install will be at /usr/local

Finish with verification.

Now put the gcc in path

And all scripts together.

tested in a shell script with version 9.2.0

or follow this article from Red Hat itself.