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 ofFOO
to generate files ininst/include
that can then be used by packageBAR
, 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 <Rcpp.h>
#include <FOO.h>
using namespace Rcpp;
// [[Rcpp::export]]
SEXP some_function() {
return FOO::foo_a();
}