I have 4.5.2 installed from the Ubuntu official repositories. I would like to install 4.6 as well to try out the C++0x features it brings.

How can I do this without breaking my system? I'm fine with the newer being default, but also want to keep the older version.

2 Answers 2


If you know your way around the command line, you should be able to compile from source and set the configuration to install in /opt.

Something along the lines of ./configure --prefix=/opt.


I don't think that there is any way to do this via dpkg or the apt package management system. Thus, your option of resort is to compile from source, making this less of an Ubuntu question, and more of a gcc question. I am sure that

  1. Compiling gcc from source is a fairly involved process, especially with special requirements such as yours.
  2. There are plenty of tutorials on the matter.

A good lead is to research setting up a "cross compiler", which in your case would use the same hardware architecture as your normal gcc.

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.