This question already has an answer here:
How can I manually install gcc tarball file in Ubuntu 12.04?
This question was marked as an exact duplicate of an existing question.
You can install packages from source with apt-get:
sudo apt-get -y build-dep gcc
apt-get source gcc
sudo dpkg -i gcc*.deb
2 years ago