Reputation: 671
I have found a C++ library from someone else which implements exactly what I need for my computations in R
. Their library contains some 30ish .cpp and .h files that contain countless dependencies on each other. Their library also contains an installer file for matlab, but I would like to make the functionality of this library available in R
.
First, I thought of using the sourceCpp
function from package Rcpp
, but its documentation says it only works with standalone files. So the only option I see for now is to go through all files in said library, copy paste all shared functions in all .cpp files that make use of them to get standalone .cpp files and then sourceCpp
them all. Is there a better way to make a whole, interdependent C++ library available in R
?
Upvotes: 0
Views: 196
Reputation: 368509
Yes, create a package. For which Rcpp.package.skeleton()
is a very good first step.
Then just drop all your source and header files into src/
and R will know how to do the rest. You only need to declare more dependencies on external libraries if you actually use them.
Then see the Rcpp Attributes vignette about exporting the access points which is essentially what you already do via [[Rcpp::export]]
etc pp.
Upvotes: 1