I want to have gcc-5 because I want c++14 support. So I removed the previous versions of gcc; gcc-4.8 and gcc-4.9 and installed gcc-5 and g++-5. But now when command gcc --version it replies:

The program 'gcc' is currently not installed. You can install it by typing:
sudo apt-get install gcc

On the other hand, if I command sudo apt-get install gcc-5, I get the reply gcc-5 is already the newest version. But if I command sudo apt-get install gcc it always tries to take gcc-4.8.

Why is this behaviour? How can I ensure I get gcc-5 when command sudo apt-get install gcc.


  • Well, /usr/bin/gcc is usually a symbolic link to the default version of gcc for your system - which you've removed. You can either create a symbolic link manually, or invoke the desired version of gcc explicitly i.e. gcc-5 --version Oct 24, 2016 at 12:51

1 Answer 1


It is a bad to update libraries from a testing PPA, unless you know what you're doing.

You're not getting any response for gcc --version because you don't have the gcc program with version 5.x available in current apt-repositories. The package-manager (here apt) have maintained two different packages for the same program but different versions 4.x and 5.x.

You can't get gcc-5 when you type sudo apt-get install gcc because it will try to get package named gcc not gcc-5 from the list of repositories defined by apt. Instead I would suggest you to get gcc-5 and then replace it with gcc or replacing an alias in ~/.bashrc file.

If you want to replace your gcc-5 with gcc you can try this gist link. Or mainly

sudo add-apt-repository ppa:ubuntu-toolchain-r/test
sudo apt-get update
sudo apt-get install gcc-5 g++-5

sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-5 60 --slave /usr/bin/g++ g++ /usr/bin/g++-5

A less recommended option would be to add

alias gcc='gcc-5

in you ~/.bashrc. It will use gcc-5 when you use it from terminal and any other calls to gcc won't trigger gcc-5.

  • I strongly advice to restrain from that PPA. updating C libraries from a testing PPA is a very ugly idea
    – Anwar
    Oct 24, 2016 at 14:42
  • Add the warning in your answer please.
    – Anwar
    Oct 24, 2016 at 16:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.