How To Install Latest GCC on Ubuntu – The GNU Compiler Collection

GNU compiler collection was originally written as the compiler for the GNU operating systems and was developed to be 100% free software. GCC includes front ends for C, C++, Objective-C, Fortran, Ada, and Go, as well as libraries for these languages (libstdc++,…).

How To Install Latest GNU Compiler Collection (GCC) on Ubuntu 14 and Ubuntu 16

sudo apt-get update && \
 sudo apt-get install build-essential software-properties-common -y && \
 sudo add-apt-repository ppa:ubuntu-toolchain-r/test -y && \
 sudo apt-get update && \
 sudo apt-get install gcc-snapshot -y && \
 sudo apt-get update && \
 sudo apt-get install gcc-6 g++-6 -y && \
 sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-6 60 --slave /usr/bin/g++ g++ /usr/bin/g++-6 && \
 sudo apt-get install gcc-4.8 g++-4.8 -y && \
 sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-4.8 60 --slave /usr/bin/g++ g++ /usr/bin/g++-4.8;

When completed, you must change to the gcc you want to work with by default. Type in your terminal:
sudo update-alternatives –config gcc

To verify if it worked. Just type in your terminal

gcc -v

If everything went fine you should see gcc 6.1.1 by the time I am writing this gist

READ  Setting up Openfire Jabber/XMPP Server on CentOS