Written by Net Llama on 08-July-2003.
Upgrading gcc is not terribly difficult, however if not done
correctly, you could end up without a functional compiler at all.
In the following instructions I'm installing gcc-3.3, which is the
latest stable release at the time of this writing, however they can
apply to any gcc-3.x release. Its worth noting that my
instructions allow you have two simultaneous versions of gcc on your
system. This provides a bit of a safety net if the new one does
not work, plus not everything compiles cleanly with gcc-3.3.
0) In order to build gcc, you'll need reasonably current versions of
make, gcc and binutils. Its quite possible to build gcc-3.x with
gcc-2.9x, however it may not work with older versions. I used
make-3.80 and binutils-2.13.90. You can get these neccesary
1) Once you've downloaded gcc-3.x, extract it, and then create a new directory called gcc-build.
2) cd into gcc-build and then issue the following command to configure gcc (note this assumes that the gcc source is in ../gcc-3.3):
../gcc-3.3/configure --enable-shared --disable-checking
--with-system-zlib --program-suffix=3 --with-gnu-ld
This command will configure all the gcc binaries and files with a 3
suffix, so that you can easily tell them apart from your current gcc
installation. For example, the new gcc binary will be gcc3.
3) Next is when everything gets compiled. This will take at least
a full hour (it took 75 minutes on my PIII-1Ghz), so find something
else to do while it chugs away. The command that you should issue
4) Assuming that the compilation completes successfully, you are ready to install the new gcc with this commmand:
5) Once this completes, you'll have the new gcc3 installed in /usr/local/bin/. At this point, in order to use the new gcc, you have (at least) two choices:
You can set this variable on a per user basis in ~/.bash_profile, or
system wide in /etc/profile. This only applies for bash, it will
differ if you use a different default shell.
- The first is to adjust the Makefile of whatever it is you're building so that it calls gcc3 rather than cc or gcc.
- The second is to set the CC environmental variable so that it
always calls gcc3 for anything that you compile. You can do this
like so: export CC=/usr/local/bin/gcc3