Using 3rd party header files with Rcpp

后端 未结 7 1961
生来不讨喜
生来不讨喜 2020-12-12 15:18

I have a header file called coolStuff.h that contains a function awesomeSauce(arg1) that I would like to use in my cpp source file.

Directo

7条回答
  •  误落风尘
    2020-12-12 15:38

    We can add it by writing path to the header in the PKG_CXXFLAGS variable of the .R/Makevars file as shown below. The following is an example of adding header file of xtensor installed with Anaconda in macOS.

    ⋊> ~ cat ~/.R/Makevars                                                                                                                              
    CC=/usr/local/bin/gcc-7
    CXX=/usr/local/bin/g++-7
    CPLUS_INCLUDE_PATH=/opt/local/include:$CPLUS_INCLUDE_PATH
    PKG_CXXFLAGS=-I/Users/kuroyanagi/.pyenv/versions/miniconda3-4.3.30/include
    LD_LIBRARY_PATH=/opt/local/lib:$LD_LIBRARY_PATH
    CXXFLAGS= -g0 -O3 -Wall
    MAKE=make -j4
    

提交回复
热议问题