Skip to content

Rcpp, best method for linking to

3 messages · Andrew Garbutt, Andrew Finley, Dominick Samperi

#
Hi Andy,
Follow the suggestions for c++ in the Writing R Extensions document.
Wrap your c++ code in extern "C"{}, include your classes in the includes
(e.g., #include "myclass.h") and put the myclass.h and myclass.cpp in
the src directory along with your other code. Then R CMD build ... and R
CMD INSTALL ...  This works for me. 
-Andy
On Fri, 2006-02-24 at 13:11 -0800, Andrew Garbutt wrote:
#
Hi Andy (and Andy),

I'm not sure why there should be any licensing issues. R itself is GPL-ed,
so I just followed this convention.

Of course, you can do it yourself with extern "C" and all that. The
purpose of Rcpp.{cpp,hpp} is to enable you to write
readable code (for a C++ programmer) while hiding the error-prone
macro gymnastics that is required to fetch R parameters when using
the .Call interface. There is also a fair amount of type checking done
in the Rcpp package that relieves you of the trouble of putting many
checks in your R code.

If you are using the older, simpler .C interface this may not be
important to you. But note that the same functionality is available
through Rcpp, with the added convenience that list item names
are not dropped like they are when you use the .C interface.

Dominick
Andrew Finley wrote: