So I'm working on a project and I wanted to use some C11 features for C. To use those features GCC 4.7 is required, so I went to synaptic and looked up 4.7, and I found the packages gcc-4.7-base so I installed it[1].

So now that gcc-4.7-base is installed I expected to be able to use 4.7, but no, when I do gcc --version it still shows 4.6.3 even more, when I try to directly call 4.7(via /usr/bin/gcc-4.7) it doesn't exist, though a gcc-4.6 executable does exist.

How do I "activate" GCC 4.7? I read here, you do some crazy stuff with update-alternatives, but it doesn't work for me as the gcc-4.7 executable doesn't actually exist on my machine.

Notes: 1. I also saw gcc-4.6-base, so I figured I'd uninstall it, but synaptic attempted to remove every package I had installed and install a Java runtime, so for obvious reason I decided not to remove it.


The following worked for me.

sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-4.6 60 --slave /usr/bin/g++ g++ /usr/bin/g++-4.6 
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-4.7 40 --slave /usr/bin/g++ g++ /usr/bin/g++-4.7 
sudo update-alternatives --config gcc

Source for reference

  • I don't think this answers the question, since the OP specifically said the update-alternatives route wouldn't work for them as they didn't have the gcc-4.7 binary available. Indeed, trying to follow the instructions in this answer after installing gcc-4.7-base results in the error: update-alternatives: error: alternative path /usr/bin/gcc-4.7 doesn't exist. – waldyrious Mar 4 '16 at 15:43

The gcc binary is in the gcc-X.Y package, not gcc-X.Y-base. The latter is a dependency of either gcc-X.Y or libstdc++.

Basically, you should simply install gcc-4.7 and then either call it as gcc-4.7 from your makefile, or use install-alternatives to make it the default.

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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