I am trying to define a function using Rcpp for speedup. The situation is as follows:
Another option, in case you don't mind introducing Rcpp
into package FOO
- follow along with Section 3.5 of Rcpp-attributes and do the following:
Place // [[Rcpp::interfaces(cpp)]]
at the top of the .cpp
source files containing functions you'd like to be made available to other packages,
Place // [[Rcpp::export]]
in front of those functions you would like exported,
Call compileAttributes()
in the package directory of FOO
to generate files in inst/include
that can then be used by package BAR
, using // [[Rcpp::depends(FOO)]]
,
Install package FOO
.
If you have this set up correctly, you should be able to call a function with a template like this (supposing foo_a
is an exported function from FOO
):
// [[Rcpp::depends(FOO)]]
#include
#include
using namespace Rcpp;
// [[Rcpp::export]]
SEXP some_function() {
return FOO::foo_a();
}