[R-SIG-Mac] .C interface to R: problem with compilation
iit512
iit512 at yandex.ru
Thu Aug 30 21:52:17 CEST 2007
Dear all,
I am trying to reproduce the simple example from Peng & Leeuw article (http://www.biostat.jhsph.edu/~rpeng/docs/interface.pdf) but have multiple errors which I cannot resolve.
The example file is hello.c:
===
#include <R.h>
void hello(int *n)
{
int i;
for(i=0; i < *n; i++) {
Rprintf("Hello, world!\n");
}
}
===
I try to compile it via
> R CMD SHLIB hello.c
and get this message:
===
gcc-4.0 -arch ppc -isysroot /Developer/SDKs/MacOSX10.4u.sdk -std=gnu99 -no-cpp-precomp -I/Library/Frameworks/R.framework/Resources/include -I/Library/Frameworks/R.framework/Resources/include/ppc -I/usr/local/include -fPIC -g -O2 -c hello.c -o hello.o
In file included from hello.c:1:
/Library/Frameworks/R.framework/Resources/include/R.h:31:20: error: stddef.h: No such file or directory
... (lot more errors)
===
I thought that the error is in "-I/usr/local/include" because I have stddef.h in /usr/include. So I tried following:
===
> MAKEFLAGS="CPPFLAGS=-I/usr/include" R CMD SHLIB hello.c
gcc-4.0 -arch ppc -isysroot /Developer/SDKs/MacOSX10.4u.sdk -std=gnu99 -no-cpp-precomp -I/Library/Frameworks/R.framework/Resources/include -I/Library/Frameworks/R.framework/Resources/include/ppc -I/usr/include -fPIC -g -O2 -c hello.c -o hello.o
In file included from /Library/Frameworks/R.framework/Resources/include/R.h:35,
from hello.c:1:
/usr/include/float.h:8:24: error: no include path in which to search for float.h
... (and lot more errors)
===
System: R 2.5.1 / Darwin Kernel Version 8.10.0 : Wed May 23 16:50:59 PDT 2007; root:xnu-792.21.3~1/RELEASE_PPC Power Macintosh powerpc / Mac OS X 10.4.10 (8R218) / PowerPC G4 (2.1)
How to resolve the problem? Any help will be appreciated.
With best wishes,
Alexey Shipunov
More information about the R-SIG-Mac
mailing list