First of all just as anywhere else mentions, you need GMP, MPFR andMPC to compile gcc. But these are not enough, you will need PPL,CLOOG and libelf too. You might try these to get from debian/ubuntu repositories but you may not be able to find them. Even if you do, you may not be able to install because of the same dependency conflicts.
You really can try to grab it from ubuntu repo if you are lucky and can find the exact version you are looking for as follow:
$ sudo apt-get install gcc-4.5 g++-4.5 $ ln -s /usr/bin/gcc-4.5 /usr/bin/gcc $ ln -s /usr/bin/g++-4.5 /usr/bin/g++
If you can’t find exact version, just got for the manual way which I prefer:
I compiled all of them manually and here are the versions used:
- and of course gcc-4.5.2
Any of those require any other library than the ones in the list, i installed using apt. After
./configure && make && make installing all dependencies i did those to get a build.
mkdir gcc-build cd gcc-build ../gcc-4.5.2/./configure --disable-ppl-version-check --enable-languages=c,c++ make -j3 make install
Creating a dir like gcc-build and building there is the preferred way of doing things, but docs say doing a build in the same directory as sources may yield unexpected results.