Rcpp 模块在 Rcpp 0.12.11 中不起作用
Posted
技术标签:
【中文标题】Rcpp 模块在 Rcpp 0.12.11 中不起作用【英文标题】:Rcpp modules not working in Rcpp 0.12.11 【发布时间】:2017-06-02 14:16:08 【问题描述】:更新 Rcpp 后,我的模块代码停止工作,我可以通过尝试安装通过 Rcpp::Rcpp.package.skeleton("foo", module=TRUE)
创建的测试包来重现此情况。
输出如下:
$ Rscript -e "Rcpp::Rcpp.package.skeleton('foo', module = TRUE)"
Creating directories ...
...
$ R CMD INSTALL foo
* installing to library ‘/home/SMARTODDS/pollockj/R/x86_64-suse-linux-gnu-library/3.4’
* installing *source* package ‘foo’ ...
** libs
g++-6 -I/usr/lib64/R/include -DNDEBUG -I"/home/SMARTODDS/pollockj/R/x86_64-suse-linux-gnu-library/3.4/Rcpp/include" -I/usr/local/include -fpic -O3 -c Num.cpp -o Num.o
g++-6 -I/usr/lib64/R/include -DNDEBUG -I"/home/SMARTODDS/pollockj/R/x86_64-suse-linux-gnu-library/3.4/Rcpp/include" -I/usr/local/include -fpic -O3 -c RcppExports.cpp -o RcppExports.o
g++-6 -I/usr/lib64/R/include -DNDEBUG -I"/home/SMARTODDS/pollockj/R/x86_64-suse-linux-gnu-library/3.4/Rcpp/include" -I/usr/local/include -fpic -O3 -c rcpp_hello_world.cpp -o rcpp_hello_world.o
g++-6 -I/usr/lib64/R/include -DNDEBUG -I"/home/SMARTODDS/pollockj/R/x86_64-suse-linux-gnu-library/3.4/Rcpp/include" -I/usr/local/include -fpic -O3 -c rcpp_module.cpp -o rcpp_module.o
g++-6 -I/usr/lib64/R/include -DNDEBUG -I"/home/SMARTODDS/pollockj/R/x86_64-suse-linux-gnu-library/3.4/Rcpp/include" -I/usr/local/include -fpic -O3 -c stdVector.cpp -o stdVector.o
g++-6 -shared -L/usr/lib64/R/lib -L/usr/local/lib64 -o foo.so Num.o RcppExports.o rcpp_hello_world.o rcpp_module.o stdVector.o -L/usr/lib64/R/lib -lR
installing to /home/SMARTODDS/pollockj/R/x86_64-suse-linux-gnu-library/3.4/foo/libs
** R
** byte-compile and prepare package for lazy loading
** help
*** installing help indices
** building package indices
** testing if installed package can be loaded
Error: package or namespace load failed for ‘foo’ in .doLoadActions(where, attach):
error in load action .__A__.1 for package foo: loadModule(module = "NumEx", what = TRUE, env = ns, loadNow = TRUE): Unable to load module "NumEx": Failed to initialize module pointer: Error in FUN(X[[i]], ...): no such symbol _rcpp_module_boot_NumEx in package foo
Error: loading failed
Execution halted
ERROR: loading failed
* removing ‘/home/SMARTODDS/pollockj/R/x86_64-suse-linux-gnu-library/3.4/foo’
任何想法如何修复,或者这是最新 Rcpp 中的错误?
> packageVersion("Rcpp")
[1] ‘0.12.11’
> sessionInfo()
R version 3.4.0 (2017-04-21)
Platform: x86_64-suse-linux-gnu (64-bit)
Running under: SUSE Linux Enterprise Desktop 12 SP2
Matrix products: default
BLAS/LAPACK: /usr/lib64/libopenblas_serial.so.0
locale:
[1] LC_CTYPE=en_GB.UTF-8 LC_NUMERIC=C LC_TIME=en_GB.UTF-8
[4] LC_COLLATE=en_GB.UTF-8 LC_MONETARY=en_GB.UTF-8 LC_MESSAGES=en_GB.UTF-8
[7] LC_PAPER=en_GB.UTF-8 LC_NAME=C LC_ADDRESS=C
[10] LC_TELEPHONE=C LC_MEASUREMENT=en_GB.UTF-8 LC_IDENTIFICATION=C
attached base packages:
[1] stats graphics grDevices utils datasets methods base
loaded via a namespace (and not attached):
[1] compiler_3.4.0
【问题讨论】:
【参考方案1】:我可以确认Rcpp.package.skeleton()
中的错误,即使使用更新的 Rcpp 0.12.11.1。
但请查看我们包含在包中的示例 Rcpp 模块包,尤其是它的 src/init.c 文件。我相当肯定我是自动生成的,所以我们应该能够通过对tools::package_native_routine_registration_skeleton()
的适当调用来修复骨架生成器。
感谢您提交错误报告。您可以(目前)手动调整src/init.c
。我提交了一个issue ticket,所以我们会看到如何为临时 Rcpp 0.12.11.2 修复它。
【讨论】:
非常感谢您的回复,德克。我想我现在会坚持使用旧版本的 Rcpp。 我想如果是我,我会选择新版本并一次性手动调整您的“src/init.c”。 修复 in this PR 因为 JJ 是达曼! 我现在从 github 安装时一切正常 - 非常感谢 Dirk + JJ!以上是关于Rcpp 模块在 Rcpp 0.12.11 中不起作用的主要内容,如果未能解决你的问题,请参考以下文章