Recently I was asked to install the latest GCC tool chain and mvapich for someone, I've done it a few times but keep forgetting what I need to install. So here are some quick notes on what I usually do. GCC 4.x, well the latest stables require that you have a few dependancies installed, such as a working compiler, your system compiler will do and two libraries.
The following was carried out on scientificlinux 4.5 based cluster.
First download the following packages
- http://gmplib.org/ - libgmp
- http://www.mpfr.org/ - libmpfr
and of course gcc itself
- http://gcc.gnu.org/ - gcc
The GCC documentation on Installing GCC was pretty useful, it can be found at http://gcc.gnu.org/install/
We first install libmpfr
tar xvjf mpfr-2.4.1.tar.bz2
cd mpfr-2.4.1
./configure --prefix=/usr/support/arch/x86_64/GCC/4.4.0 \
--exec-prefix=/usr/support/arch/x86_64/GCC/4.4.0 \
--libdir=/usr/support/arch/x86_64/GCC/4.4.0/lib64
make
make check
sudo make install
Now install libgmp
tar xvjf gmp-4.3.0.tar.bz2
cd gmp-4.3.0
./configure --prefix=/usr/support/arch/x86_64/GCC/4.4.0 \
--exec-prefix=/usr/support/arch/x86_64/GCC/4.4.0 \
--libdir=/usr/support/arch/x86_64/GCC/4.4.0/lib64
make
make check
sudo make install
Note that it is important to run a make check to be sure that these numerical libraries will give the correct numbers.
To configure and install GCC you need to set your LD_RUN_PATH and LD_LIBRARY_PATH such that configure will find the needed libraries.
export LD_LIBRARY_PATH=/usr/support/arch/x86_64/GCC/4.4.0/lib64:$LD_LIBRARY_PATH
export LD_RUN_PATH=/usr/support/arch/x86_64/GCC/4.4.0/lib64:$LD_RUN_PATH
export LDFLAGS='-L/usr/support/arch/x86_64/GCC/4.4.0/lib64 -Wl,--rpath -Wl,/usr/support/arch/x86_64/GCC/4.4.0/lib64'
tar gcc-4.4.0.tar.bz2
mkdir gcc-4.4.0-build
cd gcc-4.4.0-build
../gcc-4.4.0/configure --prefix=/usr/support/arch/x86_64/GCC/4.4.0 \
--with-gmp=/usr/support/arch/x86_64/GCC/4.4.0 \
--with-mpfr=/usr/support/arch/x86_64/GCC/4.4.0
make
sudo make install
By default these language are built,
c,c++,fortran,java,objc
You could probably replace the path /usr/support/arch/x86_64/GCC/4.4.0 with something like /usr/local or even $HOME/local
To use the compiler you will need to set a few environment variables, I prefer to prepend my environment to make sure I get the right libraries and executables.
export LD_LIBRARY_PATH=/usr/support/arch/x86_64/GCC/4.4.0/lib64:$LD_LIBRARY_PATH
export LD_RUN_PATH=/usr/support/arch/x86_64/GCC/4.4.0/lib64:$LD_RUN_PATH
export LDFLAGS='-L/usr/support/arch/x86_64/GCC/4.4.0/lib64 -Wl,--rpath -Wl,/usr/support/arch/x86_64/GCC/4.4.0/lib64'
export PATH=/usr/support/arch/x86_64/GCC/4.4.0/bin:$PATH
Your paths may differ, so set them correctly. The LDFLAGS line I guess is optional, since it just overrides the LD_RUN_PATH variable with your own custom one.
Once its all compiled and installed and my environment set, I was pretty much able to compile mvapich with the updated compilers.