How can I pass flags to R when it is compiling C++ code to be used in a package?

后端 未结 2 1157
耶瑟儿~
耶瑟儿~ 2021-02-08 06:50

I am trying to use some code from OpenCV in an R package, using Rcpp to build the package. When I compile the c code on my machine, it works fine.

For example, I am u

相关标签:
2条回答
  • 2021-02-08 07:39

    This is a Makevars file that actually worked for me:

    PKG_LIBS = `pkg-config --libs opencv`
    PKG_CFLAGS = `pkg-config --cflags opencv`
    PKG_CXXFLAGS = `pkg-config --cflags opencv` `Rscript -e 'Rcpp:::CxxFlags()'`
    PKG_CFLAGS = `pkg-config --cflags opencv`
    

    Hope this helps.

    0 讨论(0)
  • 2021-02-08 07:53

    You need to put a Makevars-File into your src directory and specify PKG_CPPFLAGS (preprocessor & includes) and PKG_CXXFLAGS (compiler flags). Details are in sections 1.2.1 and 5.5 in "Writing R Extensions".

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