See also the Installation Guide for 32-bit GFortran binaries.
Installation
Here are the essential steps:
Download the GFortran binary
- Go into directory under which you want to put GFortran
Unpack the package using tar xvfz gcc-trunk-x86_64.tar.gz, which unpacks it into the directory gcc-trunk.
The packages (starting from 4.4) already contain the following additional libraries: GMP Library, MPFR Library, Parma Polyhedra Library (PPL), and Chunky Loop Generator (CLOOG).
You may need to recompile GMP if your GLIBC is too old and you want to use OpenMP.
Using gfortran
Now you should be able to use gfortran. You should first check whether $your_path/gcc-trunk/bin/gfortran --version works and whether it shows the right date. (The first line of output should looks like: GNU Fortran (GCC) 4.4.0 20080725 (experimental).)
Remember to use either -static or set an appropriate LD_LIBRARY_PATH otherwise the gfortran.so library might not be found or the wrong library is used (e.g. older installation, system installation). You could also use -rpath (discouraged if you distribute your program). Note that your library path depends whether you compile for 32 (-m32) or 64 bit (default or -m64).
Examples for setting the LD_LIBRARY_PATH
These examples assume that you installed gfortran at /opt/gcc-trunk.
Using the sh/bash/ksh etc. shell (and 64 bit libraries):
if [ -z "$LD_LIBRARY_PATH" ]; then
LD_LIBRARY_PATH="/opt/gcc-trunk/lib64"
else
LD_LIBRARY_PATH="/opt/gcc-trunk/lib64:$LD_LIBRARY_PATH"
fi
export LD_LIBRARY_PATHand an example for 32bit using the csh/tcsh shell:
if !($?LD_LIBRARY_PATH) then
setenv LD_LIBRARY_PATH "/opt/gcc-trunk/lib"
else
setenv LD_LIBRARY_PATH "/opt/gcc-trunk/lib:$LD_LIBRARY_PATH"
endif(One should not use "/opt/gcc-trunk/lib:$LD_LIBRARY_PATH" if LD_LIBRARY_PATH is unset. The reason is that in that case the current directory is automatically included in the library path, which can be exploited by malicious users by placing a tinkered library in, e.g., /tmp.)