I have installed gcc-3.3/g++-3.3 on ubuntu 11.04 which already has gcc/g++-4.4. So in my system both gcc-3.3 and 4.4 are available. I am able to call both compilers as I want. If I just call the command
As @Tommy suggested, you should use
It assigns values to every software of a family, so that it defines the order in which the applications will be called.
It is used to maintain different versions of the same software on a system. In your case, you will be able to use several declinations of
gcc, and one will be favoured.
To figure out the current priorities of gcc, type in the command pointed out by @tripleee's comment:
update-alternatives --query gcc
Now, note the priority attributed to
gcc-4.4 because you'll need to give a higher one to
To set your alternatives, you should have something like this (assuming your
gcc installation is located at
gcc-4.4's priority is less than 50):
update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-3.3 50
Finally, you can also use the interactive interface of
update-alternatives to easily switch between versions. Type
update-alternatives --config gcc to be asked to choose the gcc version you want to use among those installed.
--edit 2 --
Now, to fix the CXX environment variable systemwide, you need to put the line indicated by @DipSwitch's in your
.bashrc file (this will apply the change only for your user, which is safer in my opinion):
echo 'export CXX=/usr/bin/gcc-3.3' >> ~/.bashrc