Use the mirrors listed Here and download the 4.8.1. The process is pretty straightforward. I would recommend to use this Procedure to complete your installation.
As you may know GCC doesn't support "make uninstall" and it has been suggested that you install GCC into a directory of its own and simply remove that directory when you do not need that specific version of GCC any longer. Hope this helped. Cheers
Edited: The Option 2:
I assume that you already have a former version of gcc, the easiest way could be adding PPA to your repositories and Update and upgrade you can have the latest version with no worries:
sudo add-apt-repository ppa:ubuntu-toolchain-r/test
sudo apt-get update
this will add the new PPA to the other sources.
Then unistall the alternative:
sudo update-alternatives --remove-all gcc
sudo update-alternatives --remove-all g++
then:
sudo apt-get install gcc-4.8
sudo apt-get install g++-4.8
and as the alternative packages install :
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-4.8 20
sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-4.8 20
sudo update-alternatives --config gcc
sudo update-alternatives --config g++
at the end:
sudo apt-get update
sudo apt-get upgrade -y
sudo apt-get dist-upgrade
Hope this changes the --version ;)
Run the following commands in sequence. I was getting same error. This worked for me.
sudo add-apt-repository ppa:ubuntu-toolchain-r/test
sudo apt-get update
sudo apt-get install gcc-snapshot
sudo apt-get install gcc-6 g++-6
Best Answer
Install a helpful tool
checkinstall
Download the source package here, e.g.
Extract the archive
Install some development packages
Go into the source folder
Configure, in my example a 64-bit-only compiler (
--disable-multilib
), for 32-bit and 64-bit support use--enable-multilib
Start the compiler and drink a coffee or two ;) This step takes some time.
Install
You could also use
sudo make install
, but withcheckinstall
you will have an installed deb package.