IMPORTANT: This page has only historical value. It does NOT apply to current R versions. See this page for current information.

NOTE: some links may be broken - older binaries have been lost in an incident.

Mandatory tools

In order to compile R for Mac OS X 10.4 or higher, you will need the following tools: (for Mac OS X 10.5 and higher look further down)

Mandatory Tools - Leopard CRAN build

R build can be built with the above requirements, but if you want to use source compilation with the CRAN build of R for Mac OS X 10.5 or higher (aka Leopard build), you will need more recent tools:

Optional tools and libraries

The following tools and libraries are optional. R can be compiled without them, but they provide additional capabilities to R.

Apple Xcode gcc-42 add-ons

Previous (older) versions

Building a universal compiler

Note: This section is now becoming obsolete given Apple's gcc 42 branch, but it is kept here until we have more definite information on Apple's Fortran support. If you're interested in compiling Apple's gcc-4.2 branch with Fortran support, add Fortran sources and use this patch: gfortran-5564.diff (for gcc-4.2 Apple build 5564/5566/5577 and GNU Fortran 4.2.4) or gfortran-5531.diff (for gcc-4.2 Apple builds 5531 or 5553 and GNU Fortran 4.2.3). Complete sources are also in /src.

Apple provides universal compilers in their Xcode tools. This means that the compiler itself can be run on both on Intel and PowerPC Macs natively. In addition, Apple's compilers can produce binaries for any of the architectures i386, ppc, x86_64 and ppc64. This mean that the same compiler suite is usable on any Mac and can target any Mac as well.

Apple also provides a special driver for all compilers such that they support additional flags such as -arch which allow us to build fat binaries in one run. Internally the driver invokes multple separate compilers, one for each distincts -arch flag and combines the result using lipo. This is highly convenient and allows for compilation of the form:
gcc -c foo.c -arch ppc -arch i386 -arch ppc64 -arch x86_64
which produces one fat object file (foo.o) containing binaries for all four architectures.

Unfortunately Apple's branch of gcc is based on a fairly old version of gcc and they don't support Fortran. (Update: 2007/11 there is some hope, Apple's gcc-42 branch can be used to compile Fortran - see binaries above - and Apple is allegedly working on an official Fortran release) Therefore it is sometimes necessary to compile gcc from the original FSF sources. However, such compilers (e.g. as provided by HPC) are very limited, because they work only on one kind of Mac (Intel or PPC) and don't support cross-compiling. Therefore is it necessary to merge Apple's approach and FSF gcc sources to create a more usable compiler for Mac OS X.

In this part I want to describe steps necessary to create such universal compiler from any gcc sources. The whole process is fully automated by a shell script which can be obtained here (it must be run sudo unless you have write-premissions in /usr/local). I have used this procedure to create the Fortran compiler available above. Run the script with "-h" flag to see all the options.

How does it work?

Conceptually Apple's drivers use naming scheme to distinguish compilers for Intel and PowerPC targets. In the Xcode installation they are called powerpc-apple-darwin8-gcc-4.0.1 and i686-apple-darwin8-gcc-4.0.1. The virtual targets ppc64 and x86_64 are compiled by adding -m64 flags to the corresponding compiler. The driver (gcc-4.0) invokes the actual compiler(s) that are needed and uses lipo to create the resulting fat object/binary.

In order to build an universal compiler suite, we need to proceed using these steps:

Was this too compilcated? Well, use the script above or just fetch the binaries which are provided in the form of a convenient Apple installer above.

(sources for open source software not linked directly)


All software is provided "as is" and any express or implied warranties, including, but but not limited to the implied warranties of merchantability and fitness for a particular purpose are disclaimed. In no event shall AT&T, the publisher, copyright owner or contributors be liable for any direct, indirect, incidental,special, exemplary, or consequential damages (including, but not limited to, procurement of substitute goods or services; loss of use, data or profits; or business interruption) however caused and on any theory of liability, whether in contract, strict liability, or tort (including negligence or otherwise) arising in any way out of the use of this software, even if advised of the possibility of such damage.