In R, using Rcpp to access C++ code, without putting all of the C++ code on a single file, how can I control the order which the files are used when compilation takes place.
Lets say I have 2 methods, methodPrimary
and methodSecondary
, I want to put each method on separate files methodPrimary.cpp
and methodSecondary.cpp
, but let say function methodPrimary
uses function methodSecondary
, as below:
methodSecodary.cpp
#include <Rcpp.h>
using namespace Rcpp;
// [[Rcpp::export]]
int methodSecondary(int i){
return(i);
}
methodPrimary.cpp
#include <Rcpp.h>
using namespace Rcpp;
// [[Rcpp::export]]
int methodPrimary(int i){
return 2*methodSecondary(i);
}
I get an error thrown, saying methodSecondary
not declared in this scope, which is understandable, since in each of the two files, there is no reference to the other. respectively.
My initial presumption was that the Rcpp compiler would handle all of this along with package construction and use of the Collate
field, seemingly not the case.
So my question is, what is the correct process to have all the files compiled/processed/declared in the correct order?