SYSTEM SPEC:
If you don't want to fix up your path you can set the PKG_CXXFLAGS
environment variable just prior to compiling.
export PKG_CXXFLAGS='`Rscript -e "Rcpp:::CxxFlags()"` -std=c++11'
For example:
In R
#generate the bare Rcpp package as usual
library(Rcpp)
Rcpp.package.skeleton("Foo",
example_code=FALSE,
attributes=TRUE,
cpp_files=c("./Foo_R_wrapper.cpp", "./Foo.h", "/Foo.cpp")
)
and in Bash
#tell the compiler to use C++11
export PKG_CXXFLAGS='`Rscript -e "Rcpp:::CxxFlags()"` -std=c++11'
#compile as usual
cd ./Foo/;
R -e 'Rcpp::compileAttributes(".",verbose=TRUE)';
cd ..;
R CMD build Foo;
#ensure that there are no bugs
R CMD check Foo;
where Foo_R_wrapper.cpp wraps a C++ function FooBar defined and implemented in Foo.h and Foo.cpp respectively.
Foo_R_wrapper.cpp could contain the following:
#include
#include "Foo.h"
// [[Rcpp::export]]
SEXP FooBar(SEXP baa)
{
Rcpp::NumericVector baa_vec(baa)
//Do something from Foo.h (to baa_vec?)
...
//etc
return baa_vec;
}