You cannot just R CMD SHLIB
this file. Because you use Rcpp attributes, you need some code to be generated from Rcpp::depends
and Rcpp::export
.
You can either call sourceCpp( 'my.cpp' )
from R if you just want standalone use of the file or use various tools such as compileAttributes
or devtools::load_all
if this file is part of a package you are developping.
But R CMD SHLIB
is not going to generate the extra code for you.
Something I have on my $PATH
and find quite useful is this RcppScript
script:
#!/usr/bin/Rscript
args <- commandArgs(TRUE)
if( "-v" %in% args ){
options( verbose = TRUE )
}
library(Rcpp)
sourceCpp( tail(args,1) )
So that you can do:
$ RcppScript my.cpp