[R-SIG-Mac] Help on using R CMD SHLIB for compiling shared libraries calling Fortran?

Simon Urbanek simon.urbanek at r-project.org
Wed Dec 14 02:51:08 CET 2011


Jooil,

most recent Xcode in Lion removes gcc-4.2, so you may want to install it from either from Xcode 4.0/4.1 or from
http://r.research.att.com/tools/

The direct link is
http://r.research.att.com/tools/gcc-42-5666.3-darwin11.pkg

Also you can remove the Fortran you installed before (using gfortran-uninstall) since more recent Fortran is part of the above package.

Cheers,
Simon


On Dec 13, 2011, at 6:17 PM, Jooil Kim wrote:

> Hello all,
> 
> I'm interested in calling some Fortran subroutines in R, and I have been trying out R CMD SHLIB.
> 
> I'm using R ver 2.14.0, and just installed the latest version of Xcode 4.2.1. I also downloaded and installed gfortran 4.2.3 (from the .dmg at http://cran.r-project.org/bin/macosx/tools/). My OS is Lion, with the latest updates (10.7.2) on a MacBook Pro about 2 years old.
> 
> So when I go to the command line and type the SHLIB command, I get:
> 
> $ R CMD SHLIB readgrid.f
> gcc-4.2 -arch x86_64 -std=gnu99 -dynamiclib -Wl,-headerpad_max_install_names -undefined dynamic_lookup -single_module -multiply_defined suppress -L/usr/local/lib -o readgrid.so readgrid.o -lgfortran -F/Library/Frameworks/R.framework/.. -framework R -Wl,-framework -Wl,CoreFoundation
> /bin/sh: gcc-4.2: command not found
> make: *** [readgrid.so] Error 127
> 
> 
> 
> I think the problem is that the SHLIB command looks for "gcc-4.2" instead of "gcc". I also get a similar error ("gcc-4.2: command not found") when I try with a very simple "foo.c" program. I've tried looking through the documentation I could find, but didn't find any relevant info. Can someone give me advise on how to do this properly? Do I need to install another version of GCC on my mac?
> 
> 
> Thanks,
> 
> Jooil
> 
> -- 
> Jooil Kim
> Postdoc Fellow
> Scripps Institution of Oceanography, UC San Diego
> Mailing address:
> 9500 Gilman Drive # 0244
> La Jolla, CA 92093-0244, USA
> For FedEx/UPS:
> 8675 Discovery Way, Vaughan Hall Rm. 447
> La Jolla, CA 92037, USA
> 
> 
> 
> 	[[alternative HTML version deleted]]
> 
> _______________________________________________
> R-SIG-Mac mailing list
> R-SIG-Mac at r-project.org
> https://stat.ethz.ch/mailman/listinfo/r-sig-mac
> 
> 



More information about the R-SIG-Mac mailing list