[R] Compiling Fortran for R : .so: mach-o, but wrong architecture

Prof Brian Ripley ripley at stats.ox.ac.uk
Tue Aug 24 23:01:52 CEST 2010


R-sig-mac is the right list for Mac-specific questions.   But

Command-line R on Snow Leopard is 64-bit
R.app is 32-bit.

So either use R32 CMD INSTALL or use R64.app.

(And as 'R' is 32-bit on Leopard, it is rather easy to get confused.)

On Tue, 24 Aug 2010, Marie-Hélène Ouellette wrote:

> Dear all,
>
> I'm trying to compile FORTRAN code to be used in R, failing miserably. I got
> a simple code function to try to figure out what is going wrong. Here is the
> code (available on the web) :
>
>
>
>      subroutine bar(n, x)
>
>      integer n
>
>      double precision x(n)
>
>      integer i
>
>
>
>      do 100 i = 1, n
>
>          x(i) = x(i) ** 2
>
>  100 continue
>
>
>
>      end
>
>
>
> 1.     I compiled the code using 'R CMD SHLIB bar.f' in the terminal. This
> created files .o and so of the same name. Got the following output in the
> terminal :
>
>
>
> R CMD SHLIB bar.f
>
> gfortran -arch x86_64   -fPIC  -g -O2 -c bar.f -o bar.o
>
> gcc -arch x86_64 -std=gnu99 -dynamiclib -Wl,-headerpad_max_install_names
> -undefined dynamic_lookup -single_module -multiply_defined suppress
> -L/usr/local/lib -o bar.so bar.o -lgfortran
> -F/Library/Frameworks/R.framework/.. -framework R -Wl,-framework
> -Wl,CoreFoundation
>
>
>
>
>
> 2.     Tried to dynamically load the code. In the R console, typed
>
>> dyn.load("~/Documents/Marietravail/articles/MRTspatial/SIMSSDenR/bar.so")
>
> Erreur dans
> dyn.load("~/Documents/Marietravail/articles/MRTspatial/SIMSSDenR/bar.so") :
>
> impossible de charger la biblioth?que partag?e
> '/Users/maryh2002/Documents/Marietravail/articles/MRTspatial/SIMSSDenR/bar.so':
> dlopen(/Users/maryh2002/Documents/Marietravail/articles/MRTspatial/SIMSSDenR/bar.so,
> 6): no suitable image found.  Did find:
> /Users/maryh2002/Documents/Marietravail/articles/MRTspatial/SIMSSDenR/bar.so:
> mach-o, but wrong architecture
>
>
>
> I have :
>
> Mac OS : 10.6.4
>
> R 2.11.0 GUI 1.33 Leopard build 32-bit (5582)
>
> Xcode version 3.2.3 64-bit
>
> Installed gfortran 4.3.2
>
>
>
> I hope this is all you need, feel free to ask me for any more info. Thank
> you for your time,
>
> MH
>
> 	[[alternative HTML version deleted]]
>
>

-- 
Brian D. Ripley,                  ripley at stats.ox.ac.uk
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford,             Tel:  +44 1865 272861 (self)
1 South Parks Road,                     +44 1865 272866 (PA)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595


More information about the R-help mailing list