Linux – Installing older version of gcc using apt-get

aptitudelinuxubuntu 12.04

i am trying to install GCC version 3.2 using apt-get. But it complains the following

root@chid-VirtualBox:/home/chid/Downloads# apt-get install gcc=3.2
Reading package lists... Done
Building dependency tree       
Reading state information... Done
E: Version '3.2' for 'gcc' was not found

I even tried with other version numbers found in the gcc website. But no luck. how to proceed with this.

Best Answer

The version you want to install needs to exist in repositories you have in your apt sources (/etc/apt directory contains various apt settings including added repositories). You can add a repository that you know that has the version you're looking for (or a PPA if you're on Ubuntu-derived distro).

You need to find the repository on the internet that has the version of the package (in this case gcc 3.2) and it should contain a line like:

deb version foobar

You should add that line to /etc/apt/sources.list and then do:

$ apt-get update
$ apt-get install gcc=3.2

Then it will find GCC 3.2 in your newly added repository. However, do note that it will most likely overwrite system's version of GCC and that can cause all sorts of trouble and is not advised unless you really know what you are doing or the system is just a virtual machine for running that particular software you need to build.

You might also need to add the GPG key for the repository and the website containing the sources.list line will likely contain information about how to do so.

Related Question