[R-SIG-Mac] architecture problems for BUILD & SHLIB

Dan Rabosky drabosky at umich.edu
Mon Jan 6 15:14:52 CET 2014


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’


 



More information about the R-SIG-Mac mailing list