How to delete the pre-installed version of GCC and G++ in ubuntu :
Open the terminal and enter the command to uninstall the old version, for example:
sudo apt-get remove gcc
sudo apt-get remove g++
After the uninstallation is complete, enter the command to install the specified version gcc4.8.5, g++4.8.5, for example:
sudo apt-get install gcc-4.8
sudo apt-get install g++-4.8
Delete the previous soft link:
sudo rm -rf /usr/bin/gcc
sudo rm -rf /usr/bin/g++
Create a new version of the soft link:
sudo ln -sf gcc-4.8 gcc
sudo ln -sf g++-4.8 g++
或者
sudo cp /usr/bin/gcc-4.8 /usr/bin/gcc
sudo cp /usr/bin/g++-4.8 /usr/bin/g++