Installing GCC on a cluster running Linux
The GNU Compiler Collection (usually shortened to GCC) is a compiler system for C (gcc), C++ (g++), Java (gcj), Ada (GNAT), Objective-C (gobjc), Objective-C++ (gobjc++), and Fortran (gfortran). Circumstances will arise when you will want to use a particular version of GCC rather than the system version.
Set the environment variables manually for GMP, MPFR and MPC. Or use modules.
module load gmp/4.3.1
module load mpfr
module load mpc
Download the appropriate file from one of the GNU mirrors. I chose the tar.gz file from Argonne National Laboratory in Illinois. Extract into somewhere sensible (e.g., cd /usr/local/scr/GCC/version
, tar xvf gcc-4.3.5.tar.gz).
Change into the extracted directory, export your source directory and your install directory.
cd 4.3.5
export SRCDIR="$(pwd)"
export PREFIX="/usr/local/gcc/4.3.5"
Remove the build directory from previously installations and cd into it.
rm -rf ../gcc-build
mkdir ../gcc-build
cd ../gcc-build
Run configure and make. Use the -j4 option if you can, as it will take a while.
"$SRCDIR"/configure --prefix="$PREFIX" --enable-shared --enable-threads=posix --enable-__cxa_atexit --enable-languages=c,c++,fortran --with-mpfr=$MPFR_DIR --with-gmp=$GMP_DIR --with-mpc=$MPC_DIR
make bootstrap -j4
make install -j4
Change into the modules directory (code>cd /usr/local/Modules/modulefiles/gcc and create (nano 4.3.5
)a new module file.
if { $loading && ![ is-loaded mpc ] } {
module load mpc
}
prepend-path LD_LIBRARY_PATH /usr/local/gcc/4.3.5/lib
prepend-path LD_LIBRARY_PATH /usr/local/gcc/4.3.5/lib64
prepend-path MANPATH /usr/local/gcc/4.3.5/man
prepend-path PATH /usr/local/gcc/4.3.5/bin