Before we get started we need to do some dependency work :(
1. Download the following applications a directory of your choice. Lets name it, $HOME/gcc-build. Extract the applications into gcc-build.
GCC - http://gcc.gnu.org/gcc-4.8/
GMP - http://gmplib.org
MPFR - http://www.mpfr.org
MPC - http://www.multiprecision.org
Binutils - http://www.gnu.org/software/binutils
2. Create another directory called " contrib " within the gcc-build directory, ending up with $HOME/gcc-build/contrib
3. Extract the applications you downloaded into the $HOME/gcc-build directory. Consider this to be our staging area. Follow the instructions in the order they are listed in as its dependency based. For example, MPFR is dependent on GMP being compiled and installed. Latest versions.
GMP:
Now that we have completed all the dependency requirements its important to update the library paths and system paths. Add the following below to $HOME/.bashrc ( User specific functions).
LD_LIBRARY_PATH=$HOME/gcc-build/contrib/mpc/lib:$HOME/contrib/gcc-build/mpfr/lib:$HOME/gcc-build/contrib/gmp/lib:$HOME/gcc-build/contrib/binutils/lib:$LD_LIBRARY_PATH
COMPILE_OF=$HOME/gcc-build/contrib/binutils/bin
PATH=$COMPILE_OF:$PATH
Logout and login to refresh the environment.
Compile GCC
Configure Modules which is a shell environment manager. Great for managing libraries and various versions of software. I have attached the template for GCC 4.8 which can be placed into the "modulefiles" directory.
1. Download the following applications a directory of your choice. Lets name it, $HOME/gcc-build. Extract the applications into gcc-build.
GCC - http://gcc.gnu.org/gcc-4.8/
GMP - http://gmplib.org
MPFR - http://www.mpfr.org
MPC - http://www.multiprecision.org
Binutils - http://www.gnu.org/software/binutils
2. Create another directory called " contrib " within the gcc-build directory, ending up with $HOME/gcc-build/contrib
3. Extract the applications you downloaded into the $HOME/gcc-build directory. Consider this to be our staging area. Follow the instructions in the order they are listed in as its dependency based. For example, MPFR is dependent on GMP being compiled and installed. Latest versions.
GMP:
- Extract with tar xfvz gmp.tar.gz
- Create $HOME/gcc-build/contrib/gmp
- Change into the directory and compile with ./configure --prefix=$HOME/gcc-build/contrib/gmp
- make && make install
- Extract with tar xfvz mpfr.tar.gz
- Create $HOME/gcc-build/contrib/mpfr
- Change into the directory and compile with ./configure --prefix=$HOME/gcc-build/contrib/mpfr --with-gmp-build=<directory in which the source is in, the extracted directory and not the binary directory>
- Extract with tar xfvz mpc.tar.gz
- Create $HOME/gcc-build/contrib/mpc
- Change into the directory and compile with ./configure --prefix=$HOME/gcc-build/contrib/mpc --with-gmp=$HOME/gcc-build/contrib/gmp --with-mpfr=$HOME/gcc-build/contrib/mpfr
- make && make install
- Extract with bunzip binutils && tar xfv binutils.tar
- Create $HOME/gcc-build/contrib/binutils
- Change into the directory and compile with ./configure --prefix=$HOME/gcc-build/contrib/binutils
- make && make install
- make target_header_dir=$HOME/gcc-build/binutils/include -C libiberty
Now that we have completed all the dependency requirements its important to update the library paths and system paths. Add the following below to $HOME/.bashrc ( User specific functions).
LD_LIBRARY_PATH=$HOME/gcc-build/contrib/mpc/lib:$HOME/contrib/gcc-build/mpfr/lib:$HOME/gcc-build/contrib/gmp/lib:$HOME/gcc-build/contrib/binutils/lib:$LD_LIBRARY_PATH
COMPILE_OF=$HOME/gcc-build/contrib/binutils/bin
PATH=$COMPILE_OF:$PATH
Logout and login to refresh the environment.
Compile GCC
- Earlier you downloaded the latest version of GCC from a mirror site into $HOME/gcc-build/ and extracted the contents in there.
- Create a directory $HOME/gcc-build/build and change directory into $HOME/gcc-build/build. Notice that we are NOT executing the "./configure" script from within the extracted directory but rather from a build directory. Its extremely important to adhere to this rule.
- cd $HOME/gcc-build/build
- "../gcc-4.8.1/configure --prefix=$HOME/gcc-build/contrib/gcc/ --enable-languages=c,c++ --with-gmp=$HOME/gcc-build/contrib/gmp --with-mpc=$HOME/gcc-build/contrib/mpc/ --with-mpfr=$HOME/gcc-build/contrib/mpfr/" ( NB: notice the importance of the two periods before the configure script )
- make -j 4 ( This assumes that you would like the compile of GCC to consume 4 CPU processors.
- make install
- make clean ( This will erase all the intermediate files )
- $HOME/gcc-build/contrib/gcc/bin/gcc –version should give show the correct version.
Configure Modules which is a shell environment manager. Great for managing libraries and various versions of software. I have attached the template for GCC 4.8 which can be placed into the "modulefiles" directory.
#%Module################## ## ## gcc 4.8.1 module ## proc ModulesHelp { } { puts stderr "Sets up the paths you need to run gcc 4.8.1" } set sys [uname sysname] set base /usr/loca/software/gcc set version 4.8.1 set basepath $base set modname [module-info name] set modmode [module-info mode] prepend-path PATH $basepath/bin prepend-path PATH $basepath/binutils/bin prepend-path LD_LIBRARY_PATH $basepath/mpfr/lib prepend-path LD_LIBRARY_PATH $basepath/mpc/lib prepend-path LD_LIBRARY_PATH $basepath/gmp/lib prepend-path LD_LIBRARY_PATH $basepath/binutils/lib64 prepend-path LD_LIBRARY_PATH $basepath/lib64