[Rcpp-devel] Ripping C source from R
Søren Højsgaard
sorenh at math.aau.dk
Mon Jul 2 07:28:38 CEST 2012
I think it is necessary that you ensure that the relevant .h files are includede (Rdefines.h etc). You could include your code in a future message.
Regards
Søren
From: rcpp-devel-bounces at lists.r-forge.r-project.org [mailto:rcpp-devel-bounces at lists.r-forge.r-project.org] On Behalf Of Silkworth,David J.
Sent: 2. juli 2012 06:40
To: rcpp-devel at lists.r-forge.r-project.org
Subject: [Rcpp-devel] Ripping C source from R
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/df6d8e05/attachment.html>
More information about the Rcpp-devel
mailing list