Thursday, April 16, 2009

GCC 4.3 on RHEL4

There comes a time when you'll need the latest (or newer compilers). Unfortunately they are not always easy to upgrade.

Here I've installed GCC 4.3 on RHEL4.4, but in principle should work for any distribution.

Download the latest version of these:

Compile binutils first

./configure --prefix=/home/craigb/binutils
make
make install

Add your new binaries to your PATH (export PATH=/home/craigb/binutils/bin:$PATH) and libraries to LD_LIBRARY_PATH (export LD_LIBRARY_PATH=/home/craigb/binutils/lib:$LD_LIBRARY_PATH) next compile GMP

./configure --prefix=/home/craigb/gmp
make
make install

Add these libraries to your LD_LIBRARY_PATH (export LD_LIBRARY_PATH=/home/craigb/gmp/lib:$LD_LIBRARY_PATH), next compile MPFR

Download the latest patches first
./configure --prefix=/home/craigb/mpfr
make
make install

Add these libraries to your LD_LIBRARY_PATH (like above), now compile GCC

cd /home/craigb/gcc-build (Note not the same folder as the source)
/home/craigb/gcc-4.3.3/configure --prefix=/home/craigb/gcc --with-gmp=/home/craigb/gmp --with-mpfr=/home/craigb/mpfr
make
make install

You should find GCC in /home/craigb/gcc/bin!

It is good practise to read the INSTALL and/or README files for all the applications before running the generic configure, make, make install above. If make check or make test is available do that as well.