Here are the steps that I took for a pretty smooth installation.
Edit: I initially used 4.1, however, I have since built gcc-4.8.0 on other (non-debian) based systems where I have not had root access. Step 4.2 should work in those cases. This has worked on CentOS 5.9 on an IvyBridge Core i7 and CentOS 6.3 on a SandyBridge based Xeon. My prefix directory in those cases were $HOME/app/gcc/4.8.0.
- Download the source code
- Unzip the file (tar -xjf <file name> for .bz2 file, like what I linked to)
- Make a build directory (mkdir gcc-build && cd gcc-build)
- Install some supporting parts
- Option 1: sudo apt-get install libgmp-dev libmpfr-dev libmpc-dev libc6-dev libc6-dev-i386
- Option 2 (from source code directory): contrib/download_prerequisites (prereqs will then be built as well)
- Run configuration (../gcc-4.8.0/configure --prefix=/app/gcc/4.8.0)
- sudo make install
I use environment modules, so I've put together a module file in modulefiles/compiler/gcc/4.8.0 which currently looks like this:
#%Modules1.0 ## ## conflict compiler prepend-path PATH /app/gcc/4.8.0/bin prepend-path LD_LIBRARY_PATH /app/gcc/4.8.0/lib64 prepend-path MANPATH /app/gcc/4.8.0/share/man prepend-path C_INCLUDE_PATH /app/gcc/4.8.0/include prepend-path CPLUS_INCLUDE_PATH /app/gcc/4.8.0/include setenv CC /app/gcc/4.8.0/bin/gcc setenv CXX /app/gcc/4.8.0/bin/g++ setenv FC /app/gcc/4.8.0/bin/gfortranAfter that, a 'module load compiler/gcc/4.8.0' and the 4.8 version of gcc, g++, and gfortran are my default C, C++ and FORTRAN compilers. Pretty simple over all.