I have a user-defined object returned from a c++ function, which is accessed in an R-code using Rcpp library in Rstudio.
When the R package is built and deployed on opencpu using 'R CMD INSTALL' the g++ compiler throws an error: ‘Result’ does not name a type.
'Result' is a c++ class which is returned by the c++ code to the calling R-code. I think R does not recognise this c++ class, but displays the Result class when typing for auto completion.
I dont understand why the command 'R CMD INSTALL' does not execute and install as expected.
The rcpp.c file
#include <Rcpp.h>
#include "Engine.h"
#include "Result.h"
using namespace Rcpp;
using Engine::execute;
// [[Rcpp::export]]
List rcpp_hello_world() {
CharacterVector x = CharacterVector::create( "foo", "bar" ) ;
NumericVector y = NumericVector::create( 0.0, 1.0 ) ;
List z = List::create( x, y ) ;
return z ;
}
// [[Rcpp::export]]
Result execute(){
printf("In cpp call!!");
ForecastingModel *fm;
InputData *sid;
int i=1;
int j=1;
utils::Time *startTime;
utils::Time *endTime;
return Engine::execute(*fm,*sid,i,j,*startTime,*endTime);
}
c++ file
#ifndef RESULT_H
#define RESULT_H
#include<string>
#include<vector>
class Result
{
private:
int status ;
std::vector<double> forecast;
std::string dataproblem ;
public:
std::string getDataproblem( );
void setDataproblem(std::string);
void setForecast(std::vector<double> );
std::vector<double>& getForecast();
int getStatus( );
void setStatus(int);
};
#endif
Any help is appreciated. Thanks!