Rcpp Rcpp.package.skeleton(“mypackage”) “rcpp_hello_world” not available for .Call() for package “mypackage”

怎甘沉沦 提交于 2019-12-20 17:35:03

问题


I've managed to get the Rcpp.package.skeleton to INSTALL in Windows by the following commands at the R prompt -

Rcpp.package.skeleton("mypackage")
system("R CMD build mypackage")
system("R CMD INSTALL mypackage")
library(mypackage)

This creates the mypackage.dll. However when I do the following commands -

rcpp_hello_world <- function(){ .Call( "rcpp_hello_world", PACKAGE = "mypackage")}
rcpp_hello_world()

I get the following error:

Error in .Call("rcpp_hello_world", PACKAGE = "mypackage") : 
"rcpp_hello_world" not available for .Call() for package "mypackage"

I run sessionInfo() and I get the following:

attached base packages:
[1] tools     stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
[1] mypackage_1.0 inline_0.3.13 Rcpp_0.11.1

Stating that my new mypackage is there.

Are there any further checks I can do to see what is happening? Any ideas?


回答1:


FWIW, I just got a similar error while retrofitting an existing R-only package with Rcpp, and the problem was a missing useDynLib(mypackage) in NAMESPACE.




回答2:


The package is tested extensively before every release, including on the Windows-using Win-builder. The regression tests even include building a package this way via a call to package.skeleton().

It is also rebuilt by CRAN post-release. Many people use it.

For all of those people, tests are appropriate and when long long cannot be used, it is #define-d away.

Now, you insist on building in a non-standard way: no source I know of recommends calling R CMD INSTALL via system(). I suspect you simply have a $PATH mishap and find another wrong g++ version.

I would suggest to do what the documentation suggests and run

  R CMD INSTALL mypackage*tar.gz

in a cmd.exe prompt.




回答3:


If the package NAMESPACE file contains the line useDynLib(mypackage, .registration = TRUE) (perhaps via a roxygen line #' @useDynLib, .registration = TRUE), then it is necessary to remove PACKAGE = "mypackage" from .C / .Call function calls:

i.e. .Call( "rcpp_hello_world", PACKAGE = "mypackage") becomes .Call("rccp_hello_world").



来源:https://stackoverflow.com/questions/22594238/rcpp-rcpp-package-skeletonmypackage-rcpp-hello-world-not-available-for-ca

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!