[R-SIG-Mac] INFO: Compiling R on Mac OS X 10.6 Snow Leopard

Simon Urbanek simon.urbanek at r-project.org
Sun Sep 6 04:28:27 CEST 2009

If you are running Mac OS X 10.6 (Snow Leopard = SL henceforth) it is  
easy to compile R, but there are a few pitfalls especially for users  
that upgrade from Leopard.

(Side note: there is no need to compile your own R, all binaries  
including the 64-bit Leopard binaries from
and corresponding binary packages from CRAN are compatible with Snow  

On a *clean* SL system (fresh install):

* install Xcode 3.2 (from SL DVD)

* install gfortran 4.2.3 from CRAN

To compile 64-bit, use

../R-devel/configure r_arch=x86_64 CC="gcc -arch x86_64" \
  CXX="g++ -arch x86_64" F77="gfortran -arch x86_64" \
  FC="gfortran -arch x86_64" OBJC="gcc -arch x86_64" \
  --x-includes=/usr/X11/include --x-libraries=/usr/X11/lib

make -j8 && make install

(replace R-devel above with the place you keep R sources, you should  
not build directly in the source directory)

For 32-bit replace all x86_64 with i386 above. (You can build both and  
install in the same place, they'll co-exist nicely).

NOTE: You must specify -arch for all compilers, because the defaults  
now differ between Apple's Xcode 3.2 compilers and our gfortran.


IMPORTANT: If you upgraded from Leopard and/or you installed R for  
Leopard (Mac OS X 10.5) you may have a old gfortran from Xcode 3.1 on  
your machine - it will NOT work on SL properly. You MUST remove it and  
use the CRAN build of gfortran (or comparable) instead. To check for  
it run "which gfortran" in the Terminal - it should show either

This is ok, you have CRAN gfortran:
Fino:~$ which gfortran

This is also ok for now, you have no gfortran, but you can install the  
one from CRAN:
Fino:~$ which gfortran

This is bad:
  Fino:~$ which gfortran

If you have /usr/bin/gfortran, remove it, e.g.
sudo rm /usr/bin/gfortran


I hope this helps, I'll also put it in the FAQ.


More information about the R-SIG-Mac mailing list