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

纵然是瞬间 提交于 2019-12-03 05:59:36

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".

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.

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