I am trying to develop an R package which uses the Sundials C library for solving differential equations. In order to not have the user install the library, I am putting the source code of the library in my package.
I have put all the header files from the library in /inst/include/sundials-2.6.2
and the .c
files in src/sundials-2.6.2
of my package folder.
From my reading of the SO posts on this topic, sourceCpp
of code in multiple files (e.g., separate .h
and .cpp
files should work if they are structured to be a part of the package. I am trying to run a example code file from the Sundials package
My code (only the beginning part) looks something like
#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 */
But, I am getting an error
fatal error: sundials/sundials_nvector.h: No such file or directory
I do example of something similar done in the following github repositories
Rcppsundials - https://github.com/AleMorales/RcppSundials.R/blob/master/src/cvode.cpp
which calls the header files using
#include <cvodes/cvodes.h> // CVODES functions and constants
#include <nvector/nvector_serial.h> // Serial N_Vector
#include <cvodes/cvodes_dense.h> // CVDense
and has incorporated the header files under the /inst/include/
folder.
This is the first package I am trying to develop and I have not used C/C++ also extensively, so there could be something very silly in how I am trying to compile this program.
Just a side note - I was able to install and run an example on my OSX machine, but currently I am working from a Windows machine that does not have Sundials installed. It does have Rtools
installed, so I can compile and run the example Rcpp
programs.
Thank you SN