[Rcpp-devel] How to export a .Call function in a closure?

Peng Yu pengyu.ut at gmail.com
Tue Aug 28 05:36:27 CEST 2012


Hi,

I have the following two functions which wrap a C++ function differently.

rcpp_hello_world=local({
  sym=getNativeSymbolInfo('rcpp_hello_world', PACKAGE='mypkg')
  function() .Call(sym, PACKAGE='mypkg')
})

rcpp_hello_world1=function(){
  .Call('rcpp_hello_world', PACKAGE='mypkg')
}

However, the first one results in some error, when I try to install
the R package. I guess the problem is that when the package is being
installed, "mypkg" is not available yet. The solution might be to put
some code in .onLoad or some code that is executed when the package is
loaded (not at installation time). However, I don't find an example.
Does anybody have any experience on how to have the first form of
.Call in a package? Thanks!

Loading required package: Rcpp
Error in FUN("rcpp_hello_world"[[1L]], ...) :
  no such symbol rcpp_hello_world in package mypkg
Calls: roxygenize ... eval -> eval -> getNativeSymbolInfo -> lapply -> FUN
Execution halted

-- 
Regards,
Peng


More information about the Rcpp-devel mailing list