While trying to compile a suitably recent Xen Dom0 Kernel for use on Ubuntu Intrepid and Jaunty instalations, I found that that derfault installed GCC compiler version 4.3 wasn actually suitable. I was getting an error at link time:
Research on the internet revealed that the cause of this was the fact that the kernel would not compile using the installed GCC. Infact people where advising to build the kernel on a machine otwith an older version of Ubuntu installed. That wasnt really practical for me, so I had a look around to see if there was a possibility to install and older c compiler on Ubuntu without causing a lot of other problems, and as it turned out its quite painless. You can even use the alternatives software to switch between them in much the same way you can java. You can do this as follows.
Firstly open a root shell like this:
sudo su -
Then install the older GCC like this:
apt-get install gcc-4.2 apt-get install g++-4.2
Then configure alternatives like this:
update-alternatives --remove-all gcc update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-4.2 42 --slave /usr/bin/g++ g++ /usr/bin/g++-4.2 --slave /usr/bin/gcov gcov /usr/bin/gcov-4.2 update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-4.3 43 --slave /usr/bin/g++ g++ /usr/bin/g++-4.3 --slave /usr/bin/gcov gcov /usr/bin/gcov-4.3
And then choose which GCC you want to use like this:
update-alternatives --config gcc
Then you can ‘exit’ the sudo root shell.
Now you can use either GCC.