c++ - 错误:在执行“R CMD INSTALL”时,“结果”没有命名类型
问题描述
我有一个从 c++ 函数返回的用户定义对象,该对象是使用 Rstudio 中的 Rcpp 库在 R 代码中访问的。
当使用“R CMD INSTALL”在 opencpu 上构建和部署 R 包时,g++ 编译器会抛出错误:“Result”没有命名类型。
'Result' 是一个 c++ 类,由 c++ 代码返回给调用 R 代码。我认为 R 不识别这个 c++ 类,但在键入自动完成时显示 Result 类。
我不明白为什么命令“R CMD INSTALL”没有按预期执行和安装。
rcpp.c 文件
#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++文件
#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
任何帮助表示赞赏。谢谢!
解决方案
推荐阅读
- postgresql - 将 PostgreSQL 连接到现有的 GIS 地理数据库
- string - 替换 ksh 脚本中路径中的目录名称
- java - 数据 null onActivityResult
- emscripten - Emscripten - 如何从 C 到 JavaScript 获取 uint8_t 数组?
- python - 如何在一段文本中搜索单词列表,一旦找到,添加到字典
- ansible - 是否有将日期字符串转换为纪元的 ansible 函数
- keras - 如何在 keras 生成器中使用 NN?
- julia - 在 Julia 中使用 ForwardDiff 时限制函数签名
- java - HTML 按钮,apache.http.client。向它发送 post 请求
- .htaccess - 如何重定向包含百分号的单个 URL?