[英]Rcpp: Include header from package into cppFunction
我有一个使用Rcpp
的软件包。 它具有int src/testr.h
定义的不同C++
函数。 现在在某个时候,我需要生成Rcpp
函数(使用cppFunction
或cxxfunction
), Rcpp
函数使用src/testr.h
定义的东西。 我怎样才能做到这一点?
我试过了,
> cxxfunction(signature(x="list") includes = c('#include "testr.h"'), body=sprintf(template, name, name))
> Rcpp::cppFunction(depends = "testr", includes = c('#include "src/testr.h"'), sprintf(template, name, name))
但
file7086270f0da.cpp:7:10: fatal error: 'testr.h' file not found
#include "testr.h"
^
快速建议:
inst/include/testr.h
; src/Makevars
条目(例如PKG_CPPFLAGS = -I../inst/include
才能使编译看起来在那里。 mypkg
,您可以添加depends="mypkg"
,R将知道为您设置-I...
我们一直在例如BH和各种Rcpp*
软件包中使用相同的技巧。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.