Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Rcpp modules not working in Rcpp 0.12.11

Tags:

r

rcpp

After updating Rcpp my code with modules stopped working, I can reproduce this by trying to install the test package created via Rcpp::Rcpp.package.skeleton("foo", module=TRUE).

Output is as follows:

$ 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’

Any ideas how to fix, or is this a bug in the latest 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
like image 205
Jeff Avatar asked Dec 07 '25 08:12

Jeff


1 Answers

I can confirm the bug in Rcpp.package.skeleton(), even with the updated Rcpp 0.12.11.1.

But look in the example Rcpp Module package we include in the package, and in particular its src/init.c file. I am fairly certain I autogenerated that, so we should be able to fix the skeleton generator with a suitable call to tools::package_native_routine_registration_skeleton().

With that, thanks for filing the bug report. You can (for now) maybe manually adjust src/init.c. I filed an issue ticket so we'll see about fixing that for an interim Rcpp 0.12.11.2.

like image 193
Dirk Eddelbuettel Avatar answered Dec 11 '25 19:12

Dirk Eddelbuettel