Marie-Hélène Ouellette
2010-Aug-24 19:01 UTC
[R] Compiling Fortran for R : .so: mach-o, but wrong architecture
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]]
Peter Dalgaard
2010-Aug-24 19:33 UTC
[R] Compiling Fortran for R : .so: mach-o, but wrong architecture
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
Prof Brian Ripley
2010-Aug-24 21:01 UTC
[R] Compiling Fortran for R : .so: mach-o, but wrong architecture
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
holstius
2010-Aug-25 16:14 UTC
[R] Compiling Fortran for R : .so: mach-o, but wrong architecture
Hi Marie, this link may be helpful if you want to build it for both architectures, 32-bit and 64-bit. I struggled with the same problem not too long ago. http://cran.rakanu.com/bin/macosx/RMacOSX-FAQ.html#Building-universal-package I ended up writing a very simple Makefile to accompany [my version of] the bar.f code. There is almost certainly a better way to do it. Maybe with Makevars? David -- View this message in context: http://r.789695.n4.nabble.com/Compiling-Fortran-for-R-so-mach-o-but-wrong-architecture-tp2337198p2338507.html Sent from the R help mailing list archive at Nabble.com.