The default gcc version in Ubuntu 10.04 LTS and 10.10 is gcc 4.4. However some programs depend on gcc 4.1.1 or gcc 4.1.2. Here’s how to install and setup gcc 4.1.3 in Ubuntu 10.04/10.10 which also works if one program need gcc 4.1.1/4.1.2 to run.

Install Gcc 4.1

gcc 4.1.3 is available default in Ubuntu 10.04/10.10 official repository, just run the command in Applications -> Accessories -> Terminal:

sudo apt-get install gcc-4.1

If you absolutely want gcc 4.1.1, refer to ubuntuforums.org.

Set gcc 4.1 as default version

After that, use this command to list installed gcc in your Ubuntu:

ls /usr/bin/gcc*

and use this command to check which is default:

gcc -v

1.) Now, add alternatives for gcc:

sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-4.4 40   
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-4.1 30

run this command which lists available versions, then type a number to set default.

sudo update-alternatives --config gcc

There are 2 choices for the alternative gcc (providing /usr/bin/gcc).

Selection Path Priority Status
————————————————————
0 /usr/bin/gcc-4.4 40 auto mode
* 1 /usr/bin/gcc-4.1 30 manual mode
2 /usr/bin/gcc-4.4 40 manual mode

2.) add alternatives for g++, i486-linux-gnu-gcc, and i486-linux-gnu-g++ and set 4.1 as default:

update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-4.4 40     
update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-4.1 30    
update-alternatives --config g++
update-alternatives --install /usr/bin/i486-linux-gnu-gcc i486-linux-gnu-gcc /usr/bin/i486-linux-gnu-gcc-4.4 40  
update-alternatives --install /usr/bin/i486-linux-gnu-gcc i486-linux-gnu-gcc /usr/bin/i486-linux-gnu-gcc-4.1 30  
update-alternatives --config i486-linux-gnu-gcc
update-alternatives --install /usr/bin/i486-linux-gnu-g++ i486-linux-gnu-g++ /usr/bin/i486-linux-gnu-g++-4.4 40  
update-alternatives --install /usr/bin/i486-linux-gnu-g++ i486-linux-gnu-g++ /usr/bin/i486-linux-gnu-g++-4.1 30  
update-alternatives --config i486-linux-gnu-g++