Re: [Rd] call fortran in R

From: Bill Northcott <>
Date: Fri 05 Aug 2005 - 07:56:46 GMT

On 04/08/2005, at 8:00 PM, Sebastien Durand wrote:
> I used a mac G5, R.2.1.1, and G77 3.4.4 and I would like to use and
> call a fortran subroutine.
> The trouble is that it seems I am not able to correctly load the
> compiled code.


> base
> 2 /Library/Frameworks/R.framework/Resources/library/grDevices/libs/
> 3 /Library/Frameworks/R.framework/Resources/library/stats/
> libs/
> 4 /Library/Frameworks/R.framework/Resources/library/methods/libs/
> 5 /Users/sebas/Desktop/Fortan_kmeans/
> Dynamic.Lookup
> 5 TRUE
I really wish someone would make these issues clear in MacOS R documentation.

MacOS X 10.3 Panther uses gcc-3.3 as its default compiler. The R binary is built with gcc-3.3 and g77 3.4 so that it will run on Panther.

MacOS X 10.4 Tiger uses gcc-4.00 as its default compiler. This causes two problems.
1. Fortran objects built with g77 cannot be linked with C/C++ objects built with gcc-4.0. So an R package with a mixture of C and Fortran code will very likely fail at some point. 2. Even if you specifically invoke gcc-3.3 and g77 the code will still fail to link because it needs a symlink /usr/lib/ libcc_dynamic.dylib which points to libgcc.a. This link is missing if the default gcc-4.0 is the selected compiler. (It is missing because it does not work with gcc-4).

If you want to build Fortran source packages on Tiger using the R binary distribution, you need to to do
'sudo gcc_select 3.3'

That command will make gcc-3.3 the default compiler and reinstate the symlink, which recreates the environment in which the R binary was built. You can always go back to gcc-4.0 with 'sudo gcc_select 4.0'.

Bill Northcott mailing list Received on Fri Aug 05 18:06:07 2005

This archive was generated by hypermail 2.1.8 : Mon 24 Oct 2005 - 22:27:35 GMT