gfortran on MacOS X

If you just want to use my precompiled gcc-with-gfortran package, use APT/RPM as written here. If you want to build gfortran for yourself, follow the instruction below.

gfortran Building Procedure (gcc-4.2 based)

gcc-4.0 that comes with Apple's standard DevTools does not include "gfortran", the GNU fortran 95 compiler. Although its source tree does include one, building gfortran from Apple's source tree requires some patching to satisfy undefined references caused by Apple's modifications that broke Language independence. Moreover, the gfortran source files are not up-to-date and require a lot of patching to be usable: I had been using the patched versions for sometime but recently switched to the version from the SVN source tree for gcc-4.2. In order to make gcc-4.2 coexist with Apple's gcc-4.0, I decided to configure gcc-4.2 to be installed under /usr/local. To build gcc-4.2, first get the source files from the official SVN site for gcc, cd into the source directory and do the following:

$ ./configure --prefix=/usr/local --disable-checking --enable-languages=c,c++,f95
$ make
$ mkdir tmp
$ make install DESTDIR=`pwd`/tmp
$ cd tmp
$ su
# chown -R root:wheel usr
# tar -zcvf gcc-4.2.0-bin.tar.gz usr
# exit

This gives you a tarball of gcc-4.2 compiler suite including gcc, g++, and gfortran, which can be expanded at the root directory to install under /usr/local.

How to Install a Precompiled Binary Package

A binary package is available as an RPM which can be installed using APT/RPM as

$ su
# apt-get update
# apt-get install gcc
# apt-get clean
# exit

Since the package is installed under /usr/local, you can use the gcc-4.2 as your default compiler suite by putting /usr/local/bin in front of /usr/bin in your PATH environmental variable.
 

REMARKS



Back to Keisuke Fujii's HEP on X Page
keisuke.fujii@kek.jp October 10, 2006