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
External library linking should be done with the following setup:
R/
inst/
|- include/
|- sundials/
|- header.h
src/
|- sundials/
|- Makevars
|- Makevars.win
|- action.cpp
man/
DESCRIPTION
NAMESPACE
Then add the following:
PKG_LIBS = $(LAPACK_LIBS) $(BLAS_LIBS) $(FLIBS)
PKG_CPPFLAGS = -I../inst/include/ -I src/sundials
To both Makevars
and Makevars.win
Here I've opted to remove the sundial version numbers from the folder names.
I've made the fixes necessary to compile the package:
https://github.com/sn248/Rcppsbmod/pull/1
Note:
The structure was:
inst/
|- include/
|- sundials/
|- arkode/
.....
|- nvector/
|- sundials/
|- header.h
This would have forced the include statements to be:
#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
I changed it so that:
inst/
|- include/
|- arkode/
.....
|- nvector/
|- sundials/
|- header.h
So, the statements will always be:
#include <cvodes/cvodes.h> // CVODES functions and constants
#include <nvector/nvector_serial.h> // Serial N_Vector
#include <cvodes/cvodes_dense.h> // CVDense