Rcpp模块在Rcpp 0.12.11中不起作用

时间:2017-06-02 14:16:08

标签: r rcpp

更新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 个答案:

答案 0 :(得分:2)

即使更新后的Rcpp 0.12.11.1,我也可以确认Rcpp.package.skeleton()中的错误。

但请查看我们在包中包含的示例Rcpp Module包,特别是其src/init.c文件。我相当肯定我自动生成了这个,所以我们应该能够通过适当调用tools::package_native_routine_registration_skeleton()来修复骨架生成器。

有了这个,感谢您提交错误报告。你可以(现在)手动调整src/init.c。我提交了issue ticket,所以我们将看到为临时Rcpp 0.12.11.2修复该问题。