Reputation: 560
I am using Ubuntu 9.10
For a particular piece of code I require GCC 3.2 but I have a higher version. Is it possible to install multiple versions and use whichever one I want to ?
Upvotes: 4
Views: 6962
Reputation: 7676
It is possible to install several versions of gcc on the same machine, where the default version is located here:
/usr/bin/gcc
Then your alternate versions could be located here:
/usr/local/gcc
Certainly adding packages is a simpler way to do it, but if you are interested in installing from source you can download the specific version you want from here:
https://bigsearcher.com/mirrors/gcc/releases/
Then to easily distinguish the versions you can add a suffix or prefix:
./configure --prefix=/usr/local/gcc --program-suffix=-10
So in this case your alternate executable would become gcc-10
. Then simply perform make
and make install
as usual.
Please note that if you get an error about GMP, MPFR or MPC files being missing then install them using:
./contrib/download_prerequisites
For details please see https://gcc.gnu.org/faq.html#multiple and Building GCC requires GMP 4.2+, MPFR 2.3.1+ and MPC 0.8.0+
Then you should have the new gcc
program installed in /usr/local/gcc/bin
instead of the default /usr/bin/gcc
, so you have to add it to your PATH
in your .bashrc
file (this is how I did it for bash):
export PATH=$PATH/usr/local/gcc/bin
So now I can so that I have both the default gcc
and the gcc-10
by doing:
$ which gcc
/usr/bin/gcc
$ which gcc-10
/usr/local/gcc/bin/gcc-10
Upvotes: 0
Reputation: 51435
yes, you can have multiple installations. You can invoke specific version using gcc-3.2
.
you can search repository using apt-cache search gcc-3
to find a package to install using apt-get install
. quick search shows only gcc-3.3 in repository, if that version does not work for you, you have to dig a bit more or install by hand. Other poster gave more details
Consider accepting previous answers to questions you have been answered, otherwise you will not get responses.
Upvotes: 1
Reputation: 11989
Have you searched the Ubuntu package archive for gcc ?
If gcc 3.3 is ok, you could download the gcc-3.3 and related .deb packages for dapper and I suspect it will install and happily co-exist with the gcc 4.4 you get with karmic. (You'll have to be sure to invoke it as gcc-3.3.)
Otherwise you would have to:
Upvotes: 1
Reputation: 10430
It is possible to have more than one, but they need to be named differently and installed to different folders. See tutorials for building cross-compiling GCC but do not build for different architecture. However, note that compiling GCC yourself is rather difficult, so fixing the application that you need to compile might be easier.
Upvotes: 0