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.3 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 gcc-4.3. In order to make gcc-4.3 coexist with Apple's gcc-4.0, I decided to configure gcc-4.3 to be installed under /usr/osxws together with other "MacOSX WS" packages. To build gcc-4.3, first get the source files from the official GCC site, cd into the source directory and do the following:

$ ./configure --prefix=/usr/osxws --disable-checking --enable-languages=c,c++,f95 --with-gmp-lib=/usr/osxws/lib --with-gmp-include=/usr/osxws/include --with-mpfr-lib=/usr/osxws/lib --with-mpfr-include=/usr/osxws/include
$ make
$ mkdir tmp
$ export CPPFLAGS='-I/usr/osxws/include'
$ make install DESTDIR=`pwd`/tmp
$ cd tmp
$ su
# chown -R root:wheel usr
# tar -zcvf gcc-4.3.0-bin.tar.gz usr
# exit

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

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/osxws, you can use the gcc-4.3 as your default compiler suite by putting /usr/osxws/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 March 26, 2008