我正在尝试开发一个R软件包,它使用日晷 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 */但是,我收到了一个错误
fatal error: sundials/sundials_nvector.h: No such file or directory我在下面的github存储库中做了类似的例子
Rcppsundials - https://github.com/AleMorales/RcppSundials.R/blob/master/src/cvode.cpp
调用头文件的
#include <cvodes/cvodes.h> // CVODES functions and constants
#include <nvector/nvector_serial.h> // Serial N_Vector
#include <cvodes/cvodes_dense.h> // CVDense并将头文件合并到/inst/include/文件夹下。
这是我尝试开发的第一个软件包,而且我也没有广泛地使用C/C++,所以在我试图编译这个程序时可能有一些非常愚蠢的东西。
顺便提醒一下--我能够在我的OSX机器上安装并运行一个示例,但目前我正在一台没有安装Sundials的Windows机器上工作。它确实安装了Rtools,所以我可以编译和运行示例Rcpp程序。
谢谢SN
发布于 2016-06-10 17:55:38
外部库链接应通过以下设置完成:
R/
inst/
|- include/
|- sundials/
|- header.h
src/
|- sundials/
|- Makevars
|- Makevars.win
|- action.cpp
man/
DESCRIPTION
NAMESPACE然后添加以下内容:
PKG_LIBS = $(LAPACK_LIBS) $(BLAS_LIBS) $(FLIBS)
PKG_CPPFLAGS = -I../inst/include/ -I src/sundialsMakevars和Makevars.win的
在这里,我选择从文件夹名中删除日晷版本号。
编辑
我已经完成了编译包所需的修补程序:
https://github.com/sn248/Rcppsbmod/pull/1
注意:
其结构是:
inst/
|- include/
|- sundials/
|- arkode/
.....
|- nvector/
|- sundials/
|- header.h这将迫使include语句如下:
#include <sundials/cvodes/cvodes.h> // CVODES functions and constants
#include <sundials/nvector/nvector_serial.h> // Serial N_Vector
#include <sundials/cvodes/cvodes_dense.h> // CVDense我改变了它是为了:
inst/
|- include/
|- arkode/
.....
|- nvector/
|- sundials/
|- header.h因此,声明将永远是:
#include <cvodes/cvodes.h> // CVODES functions and constants
#include <nvector/nvector_serial.h> // Serial N_Vector
#include <cvodes/cvodes_dense.h> // CVDensehttps://stackoverflow.com/questions/37753149
复制相似问题