Installing GCC

Download the file gcc-3.0.3.tar.gz.
tar -xzf gcc-3.0.3.tar.gz
mkdir gccbuild
cd gccbuild
../gcc-3.0.3/configure --prefix=/usr/local --enable-languages=c,c++
make bootstrap
su
Password: <give root password>
make install
exit
Unless you need the other languages, I would advise against installing them. The build will shorter (believe it or not) if you only build the c and c++ compilers.

Adding the load libraries

On Mandrake 8.1 (I don't know about Red Hat 7.2) you will also have to manually change the file /etc/ld.so.conf and add the line
/usr/local/lib
Then run
ldconfig
You will have to have root priviledge to change this file, so you'll either want to do this before you exit superuser or you'll have to su again.

Once you are content that the installation worked OK, you can remove the gccbuild directory.

Checking your path

To get this far, you would have needed to already had an older version of the compiler installed. So, we want to make sure that the version that is run by default is the one you just installed in /usr/local/bin.

You can get gcc to tell you which version it is with the command

gcc -v
If you get a line saying that the version is gcc version 3.0.3, you are fine. Otherwise, you need to reset your path. You can check your path by typing
printenv PATH
which lists directories in the order they will be searched for executables. You want /usr/local/bin to occur before /usr/bin. Assuming /usr/local/bin doesn't appear in your path already and you are using bash, you can add/edit the following lines in your .bashrc file
PATH=/usr/local/bin:$PATH:.
export PATH
Also make sure . appears in your path, or you'll spend your time typing ./myprogram to execute your programs.