This is how you can use different gcc compillers for the same installation.
# Link gcc and g++ versions first (versions must be installed before)
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-4.8 60 --slave /usr/bin/g++ g++ /usr/bin/g++-4.8
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-3.4 40 --slave /usr/bin/g++ g++ /usr/bin/g++-3.4
# Set the version to be used
sudo update-alternatives --config gcc
# sudo update-alternatives --config gcc
# There are 2 choices for the alternative gcc (providing /usr/bin/gcc).
#
# Selection Path Priority Status
# ------------------------------------------------------------
# * 0 /usr/bin/gcc-4.8 60 auto mode
# 1 /usr/bin/gcc-3.4 40 manual mode
# 2 /usr/bin/gcc-4.8 60 manual mode
#
# Press enter to keep the current choice[*], or type selection number: