How to build a R package which use Rcpp with external c++ libraries?

后端 未结 2 1587
囚心锁ツ
囚心锁ツ 2020-12-01 15:25

Such as boost, where can I specify the following:

1.External c++ header file include path 
2.External c++ source file 
3.External c++ link library file path         


        
相关标签:
2条回答
  • 2020-12-01 15:33

    Dirk's paper "Thirteen Simple Steps for Creating An R Package with an External C++ Library" gives an example src/Makevars:

    CXX_STD = CXX11
    PKG_CFLAGS = -I. -DGMP -DSKIP_MAIN
    PKG_LIBS = $(LAPACK_LIBS) $(BLAS_LIBS) $(FLIBS) -lgmpxx -lgmp
    

    As you can see, additional libraries are specified in PKG_LIBS in this file. The src/Makevars approach assumes that you incorporate C++ code into your project using a standard package layout, as produced by Rcpp.package.skeleton(), with NAMESPACE and DESCRIPTION and so on.

    According to Dirk's comments above, there is currently no way to specify an external library when C++ code is incorporated using the sourceCpp function, because that function provides an interface which is supposed to be multi-platform.

    0 讨论(0)
  • 2020-12-01 15:52

    It all goes into src/Makevars as explained in

    • the fine manual Writing R Extensions that came with R

    • either the Writing a package using Rcpp vignette or my book both of which I told you about in ...

    • ... my replies to your post on rcpp-devel

    0 讨论(0)
提交回复
热议问题