This question already has an answer here:
How can I manually install gcc tarball file in Ubuntu 12.04?
This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new 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
1 year ago