[Rcpp-devel] Ripping C source from R

Silkworth,David J. SILKWODJ at airproducts.com
Mon Jul 2 06:40:20 CEST 2012


I am attempting to take a copy of the entire splines.c file and use this for compilation into a new project (so I can call spline_basis() directly, but preserve the identity and integrity of the original work.

When I tried to pack this code into the include for the inline cxxfunction call I ended up with compile errors like:

file81b983.cpp: In function 'SEXPREC* spline_basis(SEXPREC*, SEXPREC*, SEXPREC*, SEXPREC*)':
file81b983.cpp:143:1: error: 'coerceVector' was not declared in this scope
file81b983.cpp:144:35: error: 'length' was not declared in this scope
file81b983.cpp:156:1: error: 'allocMatrix' was not declared in this scope
file81b983.cpp:157:1: error: 'allocVector' was not declared in this scope
file81b983.cpp:179:33: error: 'install' was not declared in this scope
file81b983.cpp:179:43: error: 'setAttrib' was not declared in this scope

These errors pertain to lines like:
PROTECT(knots = coerceVector(knots, REALSXP));
PROTECT(val = allocMatrix(REALSXP, sp->order, nx));

I tried a similar action on the famous convolve2 code from "Writing R Extensions" with very similar result.
( I also tried adding the pre-pended directive 'extern "C" 'to the function declaration.)

I am pretty sure that the problem has to do with compiling C code using a C++ compiler, but I thought I  might get away with it.

Does this prompt any thoughts, or should I just give up on this path.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.r-forge.r-project.org/pipermail/rcpp-devel/attachments/20120702/729471d5/attachment.html>


More information about the Rcpp-devel mailing list