12.04 GCC – How to Activate GCC 4.7 Version

12.04gcc

I have gcc 4.6.3 installed:

gcc --version

gcc (Ubuntu/Linaro 4.6.3-1ubuntu5) 4.6.3

I have installed newer version:

apt-get install gcc-4.7

But i still get result "gcc 4.6.3" when I type gcc --version. How to fix it?

I am using ubuntu 12.04 and i have done

sudo apt-get update
sudo apt-get upgrade

Best Answer

This is because you have both versions installed, with 4.6 being treated as the default one.

You can explicitly choose which one to use.

$ gcc-4.7 --version
gcc-4.7 (Ubuntu/Linaro 4.7.2-22ubuntu4) 4.7.2
[...]

$ gcc-4.6 --version
gcc-4.6 (Ubuntu/Linaro 4.6.3-15ubuntu3) 4.6.3
[...]

The easiest way make gcc-4.7 the default gcc is to move the symlink of /usr/bin/gcc:

sudo rm /usr/bin/gcc
sudo ln -s /usr/bin/gcc-4.7 /usr/bin/gcc
Related Question