[Rcpp-devel] Rcpp Module Errors
Dirk Eddelbuettel
edd at debian.org
Wed Jun 22 01:17:11 CEST 2011
On 21 June 2011 at 16:51, Andrew Redd wrote:
| I apologize if this has been covered. I've looked and see a couple of post
| relating to this issue, but I'm not sure if it was ever solved. The example
| modules appear to not work, at least for me. On a related note I can't get my
| modules to run either, but If I can figure out how to run the examples I think
| I can get mine running.
|
| R> sessionInfo()
| R version 2.13.0 (2011-04-13)
| Platform: x86_64-pc-linux-gnu (64-bit)
|
| locale:
| [1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C
| [3] LC_TIME=en_US.UTF-8 LC_COLLATE=en_US.UTF-8
| [5] LC_MONETARY=C LC_MESSAGES=en_US.UTF-8
| [7] LC_PAPER=en_US.UTF-8 LC_NAME=C
| [9] LC_ADDRESS=C LC_TELEPHONE=C
| [11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C
|
| attached base packages:
| [1] stats graphics grDevices utils datasets methods base
|
|
| other attached packages:
| [1] Rcpp_0.9.4
|
| To install the package skeleton:
| $ r -lRcpp -e"Rcpp.package.skeleton(\"test\",module=T)"
| Attaching package: 'utils'
|
| The following object(s) are masked from 'package:Rcpp':
|
| .DollarNames, prompt
|
| Creating directories ...
| Creating DESCRIPTION ...
| Creating NAMESPACE ...
| Creating Read-and-delete-me ...
| Saving functions and data ...
| Making help files ...
| Done.
| Further steps are described in './test/Read-and-delete-me'.
|
| Adding Rcpp settings
| >> added RcppModules: yada
| >> added Depends: Rcpp
| >> added LinkingTo: Rcpp
| >> added useDynLib directive to NAMESPACE
| >> added Makevars file with Rcpp settings
| >> added Makevars.win file with Rcpp settings
| >> added example header file using Rcpp classes
| >> added example src file using Rcpp classes
| >> added example R file calling the C++ example
| >> added Rd file for rcpp_hello_world
| >> copied the example module
|
| build
| $ R CMD build test
| <<output omitted>>
|
| and check with an error.
| $R CMD check test_1.0.tar.gz
| <<output omitted>>
| * checking whether the name space can be loaded with stated dependencies ...
| WARNING
| Error: .onLoad failed in loadNamespace() for 'test', details:
| call: value[[3L]](cond)
| error: failed to load module yada from package test
| Execution halted
|
| <<output omitted>>
|
| According to Dirk's June 15th post on the issue I include require("methods",
| character=TRUE, quietly=TRUE) in the .onLoad function, now checks ok but when
| trying things out I get a segmentation fault.
| $ R -q --vanilla
| R> library(test)
| Loading required package: Rcpp
| R> Module('yada','test')$bla()
|
| *** caught segfault ***
| address 0x90, cause 'memory not mapped'
|
| Traceback:
| 1: .Call(symbol)
| 2: Module(module, mustStart = TRUE)
| 3: .getModulePointer(x)
| 4: Module("yada", "test")$bla
|
| Possible actions:
| 1: abort (with core dump, if enabled)
| 2: normal R exit
| 3: exit R without saving workspace
| 4: exit R saving workspace
| Selection:
|
| So questions are:
| 1) is anyone else getting this error?
| 2) does anyone know how to fix it?
I just checked my very own (and small) RcppBDT which uses Rcpp modules; it
still builds. As do the regression tests.
If your code fails, you may need to compare against the docs in the
Rcpp-modules vignette, its code and the Rcpp modules unittest:
The unit test still works here ( and ~/bin/runit.sh is a trivial shell and
littler script wrapper included below ):
edd at max:~/svn/rcpp/pkg/Rcpp/inst/unitTests$ ~/bin/runit.sh -p RUnit,Rcpp runit.Module.client.package.R
Executing test function test.Module.package ... * checking for file ‘testRcppModule/DESCRIPTION’ ... OK
* preparing ‘testRcppModule’:
* checking DESCRIPTION meta-information ... OK
* cleaning src
* checking for LF line-endings in source and make files
* checking for empty or unneeded directories
* building ‘testRcppModule_0.1.tar.gz’
* installing *source* package ‘testRcppModule’ ...
** libs
ccache g++-4.5 -I/usr/share/R/include -I"/usr/local/lib/R/site-library/Rcpp/include" -fpic -g -O3 -Wall -pipe -pedantic -Wno-variadic-macros -c Num.cpp -o Num.o
ccache g++-4.5 -I/usr/share/R/include -I"/usr/local/lib/R/site-library/Rcpp/include" -fpic -g -O3 -Wall -pipe -pedantic -Wno-variadic-macros -c rcpp_hello_world.cpp -o rcpp_hello_world.o
ccache g++-4.5 -I/usr/share/R/include -I"/usr/local/lib/R/site-library/Rcpp/include" -fpic -g -O3 -Wall -pipe -pedantic -Wno-variadic-macros -c rcpp_module.cpp -o rcpp_module.o
ccache g++-4.5 -I/usr/share/R/include -I"/usr/local/lib/R/site-library/Rcpp/include" -fpic -g -O3 -Wall -pipe -pedantic -Wno-variadic-macros -c stdVector.cpp -o stdVector.o
g++ -shared -o testRcppModule.so Num.o rcpp_hello_world.o rcpp_module.o stdVector.o -L/usr/local/lib/R/site-library/Rcpp/lib -lRcpp -Wl,-rpath,/usr/local/lib/R/site-library/Rcpp/lib -L/usr/lib64/R/lib -lR
installing to /tmp/RtmpGXLL47/file53c4b34a/templib/testRcppModule/libs
** R
** preparing package for lazy loading
** help
*** installing help indices
** building package indices ...
** testing if installed package can be loaded
* DONE (testRcppModule)
Loading required package: testRcppModule
done successfully.
edd at max:~/svn/rcpp/pkg/Rcpp/inst/unitTests$
That is with a recent SVN version, but it should be the same for Rcpp 0.9.4
as released.
(For argument's sake here is ~/bin/runit.sh:
edd at max:~/svn/rcpp/pkg/Rcpp/inst/unitTests$ cat ~/bin/runit.sh
#!/bin/sh
set -u
set -e
progname=`basename $0`
options='p:h?'
usage_and_exit()
{
echo "Usage: $progname [-p package[,package2,..]] [-?|-h]"
echo " Run unit test script for R package"
echo "Options:"
echo " -p package[,package2,..]] load additional package(s)"
echo " -h show this help"
exit 0
}
while getopts "$options" i
do
case "$i" in
p)
pkg=",$OPTARG"
shift
shift
;;
h|?)
usage_and_exit
;;
esac
done
if [ ! -f $1 ]; then
echo "Error: No file '$1' found"
exit 1
fi
file=`pwd`/$1
r -i -t -lRUnit${pkg} -e"cppfunction <- function(...) cxxfunction(..., plugin=\"Rcpp\"); runTestFile(\"$file\")"
edd at max:~/svn/rcpp/pkg/Rcpp/inst/unitTests$
Hth, Dirk
|
| Thanks,
| Andrew
|
|
| ----------------------------------------------------------------------
| _______________________________________________
| Rcpp-devel mailing list
| Rcpp-devel at lists.r-forge.r-project.org
| https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/rcpp-devel
--
Gauss once played himself in a zero-sum game and won $50.
-- #11 at http://www.gaussfacts.com
More information about the Rcpp-devel
mailing list