相关疑难解决方法(0)

使用Rcpp在R包中添加外部库

我正在尝试开发一个R包,它使用Sundials C库来求解微分方程.为了不让用户安装库,我将库的源代码放在我的包中.

我已将库中的所有头文件/inst/include/sundials-2.6.2和我的包文件夹中的.c文件放入src/sundials-2.6.2.

从我对这个主题的SO帖子的阅读,sourceCpp多个文件中的代码(例如,如果它们被构造成包的一部分,则单独.h.cpp文件应该有用.我试图从Sundials包中运行示例代码文件

我的代码(只是开头部分)看起来像

#include <Rcpp.h>

#include "../inst/include/sundials-2.6.2/cvode/cvode.h"             /* prototypes for CVODE fcts., consts. */
#include "../inst/include/sundials-2.6.2/nvector/nvector_serial.h"  /* serial N_Vector types, fcts., macros */
#include "../inst/include/sundials-2.6.2/cvode/cvode_dense.h"      /* prototype for CVDense */
#include "../inst/include/sundials-2.6.2/sundials/sundials_dense.h" /* definitions DlsMat DENSE_ELEM */
#include "../inst/include/sundials-2.6.2/sundials/sundials_types.h" /* definition of type realtype */
Run Code Online (Sandbox Code Playgroud)

但是,我收到了一个错误

fatal error: sundials/sundials_nvector.h: No such file or directory
Run Code Online (Sandbox Code Playgroud)

我在以下github存储库中做了类似的例子

Rcppsundials - https://github.com/AleMorales/RcppSundials.R/blob/master/src/cvode.cpp

使用调用头文件

#include <cvodes/cvodes.h>           // CVODES functions and …
Run Code Online (Sandbox Code Playgroud)

rcpp r-package

4
推荐指数
1
解决办法
1239
查看次数

标签 统计

r-package ×1

rcpp ×1