[R-SIG-Mac] tools for compiling R from source on Leopard

Simon Urbanek simon.urbanek at r-project.org
Sun Mar 2 17:04:53 CET 2008


Michael,

the instructions you are referring to (gcc-4.2-based) are for  
experimental R builds using cutting-edge unreleased tools, so you're  
pretty much on your own there. So let me first address "offical" way  
as documented in the FAQ:
The gfortran compiler the FAQ refers to is on CRAN (http://cran.r-project.org/bin/macosx/tools 
) - it is also the first download on the R for Mac Tools page. That is  
all you need (Xcode + the above Fortran) and both the FAQ and the  
tools page specifically say so.

Now to your quest for experimental, unsupported tools (see also  
comments inline below). The only reason to use gcc-4.2 is if you want  
to play with OpenMP. Note that the gcc-4.2 is known to have bugs, so  
tread with care.


> Hi.  This week I received my very first Mac (I was previously a  
> Linux  user), and I am now trying to compile R from source.  I am  
> running Mac  OS 10.5.2, and I have downloaded and installed Xcode  
> 3.0.  Following  instructions on the R for Mac OS FAQ page I see  
> that I need to install  gfortran 4.2.1.  However, Xcode only comes  
> with gcc 4.0.1, and I  understand that the versions need to be the  
> same.
>

That is not true (and I'm not sure why concluded it). Only the major  
version (3.x vs 4.x) has to match (as the FAQ tells you), so gcc 4.0.1  
+ gfortran 4.2.1 are just fine.


> The R for Mac tools site mentions that the Apple version for gcc  
> 4.2.1 is available from ADC, but I just cannot find it anywhere

ADC: http://connect.apple.com/
Login, click on Downloads -> Developer Tools -> GCC 4.2 Developer  
Preview 1
If it's not there, please let me know.

> (I Googled, searched, etc, with no luck--can someone please point me  
> in the right direction?).  So, I ran  the provided  
> gcc42build5531.pkg installation file.  The installer ran with no  
> errors, but it doesn't seem to install anywhere

Try typing
gcc-4.2


> (I even created a test folder to install to, but after the  
> installation, that folder was empty).

Which is expected - try enabling the installer log (Window->Installer  
Log) if you're interested in the details. If you're more comfortable  
with command-line tools and want to learn more about packages on OS X,  
have a look at "man pkgutil" and "man installer". For old-style  
packages (which are bundles) see also "man pax" and "man lsbom".


>   gcc --version still indicates that the version is 4.0.1.

Yes, gcc is a link to gcc-4.0, not to gcc-4.2.


>  The gfortran-42.pkg file installed correctly.
>
> I know this sounds more like a Mac OS problem than an R problem,

There is no problem, really ;).


> but since I am using tools (and following instructions)
> designed specifically for R, I thought I'd ask for help here.   I  
> suppose that all I really need is to be able to effectively install  
> either gcc 4.2.1 (since I have the R-approved gfortran 4.2.1  
> installed) or an R-approved gfortran 4.0.1 (since I have gcc  
> 4.0.1installed).
>

No, that is wrong (see above). If you followed the instructions you'd  
use gcc 4.0.1 from Apple and gfortran 4.2.1 from CRAN. This is how the  
release is built.

FWIW: Although it is a nice exercise, I'm not quite sure why you want  
to build R from sources unless you want to modify it - note that your  
result is likely to be incompatible with the packages we create  
(unless you build the full multi-arch universal build).

One more side-note on the tools: now that you have installed several  
tools in your system (gcc 4.0, 4.2, two different gfortrans etc.), you  
should be aware that although you can use any combination of them, the  
library lookup is common to all, so unless you de-install the gfortran  
from /usr/local/bin (the CRAN verison) [via /usr/local/bin/gfortran- 
uninstall], even the binaries compiled with the Leopard gfotran (/usr/ 
bin/gfortran-4.2] will be linked to the /usr/local/lib/libgfortran  
dynamic library, because it has higher precedence than the static  
library that the system gfortran supplies. This is not really a  
problem as long as you are aware of it, but it that reduces the  
portability of your binaries a bit (you'll have to ship the gfortran  
shared library with your binaries if they use Fortran). If you don't  
understand what I'm saying, don't worry too much :) it doesn't affect  
anything as long as you stay on the same machine.

Cheers,
Simon



More information about the R-SIG-Mac mailing list