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

Peter Dalgaard pdalgd at gmail.com
Tue Aug 24 21:33:52 CEST 2010


On 08/24/2010 09:01 PM, 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,

Looks like you are trying to load a 64 bit module into a 32 bit R. Does
it work better with R64?

-- 
Peter Dalgaard
Center for Statistics, Copenhagen Business School
Phone: (+45)38153501
Email: pd.mes at cbs.dk  Priv: PDalgd at gmail.com



More information about the R-help mailing list