Hi- I am building a package that includes C code. When I try to compile the source files using SHLIB (or build the package using BUILD), it fails because it builds for the wrong architecture. Specifically, SHLIB and BUILD specify "-arch i386" by default on my machine. When I override and compile manually with "-arch x86_64", it is fine. I'm unsure how to deal with this problem. Where are the configuration files that SHLIB and BUILD are using that specify the compiler and the architecture? I'm using R v3.0.2 on OSX 10.7.5. Would this have anything to do with settings in /Library/Frameworks/R.framework/Versions/3.0/Resources/etc/Makeconf ? If so, I see nothing in there about i386: rather, -arch x86_64 is specified. Thanks in advance. Full error message below. I have the same issue if I just compile with SHLIB and try to load them (though it's fine if I compile with gcc -arch x86_64, then load the *.so files). I'd also love to know how to configure things so that SHLIB and BUILD call a particular compiler, and where I would add any path variables that need to be added for this to work. ~Dan Rabosky R commands from bash: R CMD BUILD testpackage R CMD INSTALL testpackage_1.0.tar.gz Then: * installing to library ?/Library/Frameworks/R.framework/Versions/3.0/Resources/library? * installing *source* package ?testpackage? ... ** libs gcc-4.0 -arch i386 -std=gnu99 -I/Library/Frameworks/R.framework/Resources/include -DNDEBUG -I/usr/local/include -fPIC -g -O2 -c dtrates.c -o dtrates.o gcc-4.0 -arch i386 -std=gnu99 -I/Library/Frameworks/R.framework/Resources/include -DNDEBUG -I/usr/local/include -fPIC -g -O2 -c treetraverse.c -o treetraverse.o gcc-4.0 -arch i386 -std=gnu99 -dynamiclib -Wl,-headerpad_max_install_names -undefined dynamic_lookup -single_module -multiply_defined suppress -L/usr/local/lib -L/usr/local/lib -o testpackage.so dtrates.o treetraverse.o -F/Library/Frameworks/R.framework/.. -framework R -Wl,-framework -Wl,CoreFoundation ld: warning: in /Library/Frameworks/R.framework/R, file was built for unsupported file format which is not the architecture being linked (i386) installing to /Library/Frameworks/R.framework/Versions/3.0/Resources/library/testpackage/libs ** R ** data ** preparing package for lazy loading ** help *** installing help indices ** building package indices ** testing if installed package can be loaded Error in dyn.load(file, DLLpath = DLLpath, ...) : unable to load shared object '/Library/Frameworks/R.framework/Versions/3.0/Resources/library/testpackage/libs/testpackage.so': dlopen(/Library/Frameworks/R.framework/Versions/3.0/Resources/library/testpackage/libs/testpackage.so, 6): no suitable image found. Did find: /Library/Frameworks/R.framework/Versions/3.0/Resources/library/testpackage/libs/testpackage.so: mach-o, but wrong architecture Error: loading failed Execution halted ERROR: loading failed * removing ?/Library/Frameworks/R.framework/Versions/3.0/Resources/library/testpackage? * restoring previous ?/Library/Frameworks/R.framework/Versions/3.0/Resources/library/testpackage?
architecture problems for BUILD & SHLIB
2 messages · Dan Rabosky, Brian Ripley
6 days later
-arch i386 is not specified in R itself (and neither is gcc-4.0). As a guess you have a personal Makevars file, either in the package sources or under ~/.R . See http://cran.r-project.org/doc/manuals/r-release/R-admin.html#Customizing-package-compilation .
On 06/01/2014 14:14, Dan Rabosky wrote:
Hi- I am building a package that includes C code. When I try to compile the source files using SHLIB (or build the package using BUILD), it fails because it builds for the wrong architecture. Specifically, SHLIB and BUILD specify "-arch i386" by default on my machine. When I override and compile manually with "-arch x86_64", it is fine. I'm unsure how to deal with this problem. Where are the configuration files that SHLIB and BUILD are using that specify the compiler and the architecture? I'm using R v3.0.2 on OSX 10.7.5. Would this have anything to do with settings in /Library/Frameworks/R.framework/Versions/3.0/Resources/etc/Makeconf ? If so, I see nothing in there about i386: rather, -arch x86_64 is specified. Thanks in advance. Full error message below. I have the same issue if I just compile with SHLIB and try to load them (though it's fine if I compile with gcc -arch x86_64, then load the *.so files). I'd also love to know how to configure things so that SHLIB and BUILD call a particular compiler, and where I would add any path variables that need to be added for this to work.
That is in the OS X section of the same manual, with examples.
~Dan Rabosky R commands from bash: R CMD BUILD testpackage R CMD INSTALL testpackage_1.0.tar.gz Then: * installing to library ?/Library/Frameworks/R.framework/Versions/3.0/Resources/library? * installing *source* package ?testpackage? ... ** libs gcc-4.0 -arch i386 -std=gnu99 -I/Library/Frameworks/R.framework/Resources/include -DNDEBUG -I/usr/local/include -fPIC -g -O2 -c dtrates.c -o dtrates.o gcc-4.0 -arch i386 -std=gnu99 -I/Library/Frameworks/R.framework/Resources/include -DNDEBUG -I/usr/local/include -fPIC -g -O2 -c treetraverse.c -o treetraverse.o gcc-4.0 -arch i386 -std=gnu99 -dynamiclib -Wl,-headerpad_max_install_names -undefined dynamic_lookup -single_module -multiply_defined suppress -L/usr/local/lib -L/usr/local/lib -o testpackage.so dtrates.o treetraverse.o -F/Library/Frameworks/R.framework/.. -framework R -Wl,-framework -Wl,CoreFoundation ld: warning: in /Library/Frameworks/R.framework/R, file was built for unsupported file format which is not the architecture being linked (i386) installing to /Library/Frameworks/R.framework/Versions/3.0/Resources/library/testpackage/libs ** R ** data ** preparing package for lazy loading ** help *** installing help indices ** building package indices ** testing if installed package can be loaded Error in dyn.load(file, DLLpath = DLLpath, ...) : unable to load shared object '/Library/Frameworks/R.framework/Versions/3.0/Resources/library/testpackage/libs/testpackage.so': dlopen(/Library/Frameworks/R.framework/Versions/3.0/Resources/library/testpackage/libs/testpackage.so, 6): no suitable image found. Did find: /Library/Frameworks/R.framework/Versions/3.0/Resources/library/testpackage/libs/testpackage.so: mach-o, but wrong architecture Error: loading failed Execution halted ERROR: loading failed * removing ?/Library/Frameworks/R.framework/Versions/3.0/Resources/library/testpackage? * restoring previous ?/Library/Frameworks/R.framework/Versions/3.0/Resources/library/testpackage?
_______________________________________________ R-SIG-Mac mailing list R-SIG-Mac at r-project.org https://stat.ethz.ch/mailman/listinfo/r-sig-mac
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