Adding an external library in R package using Rcpp

纵饮孤独 提交于 2019-11-30 10:11:56

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.

Edit

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
标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!