|
转自http://gcc.gnu.org/wiki/GFortranBinaries64Linux
Here are the essential steps:
Download the GFortran binary
Unpack the package using tar xvfz gcc-trunk-x86_64.tar.gz, which unpacks it into the directory gcc-trunk.
You may need to install some additional libraries:
The GMP Library is definitely needed for most programs
The MPFR Library might be needed
Depending on your distribution, a sufficient version of these libraries might be available. Otherwise you can get the libraries (lib64*.tar.gz) used on the build server; unpack those into gcc-trunk/.
Now you should be able to use gfortran. You should first check whether $your_path/gcc-trunk/gfortran --version works and whether it shows the right date. (The first line of output should looks like: GNU Fortran 95 (GCC) 4.2.0 20060725 (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).
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_PATH
and 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.)
Archiver|手机版|科学网 ( 京ICP备07017567号-12 )
GMT+8, 2024-10-6 16:30
Powered by ScienceNet.cn
Copyright © 2007- 中国科学报社