I have a package that uses Rcpp
. It has different C++
function defined int src/testr.h
. Now at some point I need to generate Rcpp
functions (using cppFunction
or cxxfunction
) that use things defined in src/testr.h
. How can I do that?
I tried,
> 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))
But
file7086270f0da.cpp:7:10: fatal error: 'testr.h' file not found
#include "testr.h"
^
Quick suggestion:
inst/include/testr.h
; src/Makevars
entry such as PKG_CPPFLAGS = -I../inst/include
to have the compilation look there. mypkg
, you can add a depends="mypkg"
and R will know to set a -I...
for you. We use the same trick all the time in eg BH and various Rcpp*
packages.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.