I was learning Rcpp and got the following problem in a basic example. <div>I have searched online and knew someone have the same problem before, </div><div>but did not find a good answer for this. </div><div><div><br></div>
<div>Simply put, I am running the following script:</div><div><br></div><div><div>rm -rf rcppapp1</div><div>R -q -e "library(Rcpp); Rcpp.package.skeleton(name = 'rcppapp1', module = TRUE);sessionInfo()"</div>
<div>R CMD build rcppapp1</div><div>R CMD INSTALL rcppapp1</div><div>R -q -e "require(Rcpp);require('rcppapp1');m1<-Module('yada', 'rcppapp1');m1\$hello()"</div><div><br></div><div><br>
</div></div><div>But I could not run the hello function defined in the model yada. </div><div>Here is the output:</div><div><br></div><div><div>+ rm -rf rcppapp1</div><div>+ R -q -e 'library(Rcpp); Rcpp.package.skeleton(name = '\''rcppapp1'\'', module = TRUE);sessionInfo()'</div>
<div>> library(Rcpp); Rcpp.package.skeleton(name = 'rcppapp1', module = TRUE);sessionInfo()</div><div>Creating directories ...</div><div>Creating DESCRIPTION ...</div><div>Creating NAMESPACE ...</div><div>Creating Read-and-delete-me ...</div>
<div>Saving functions and data ...</div><div>Making help files ...</div><div>Done.</div><div>Further steps are described in './rcppapp1/Read-and-delete-me'.</div><div><br></div><div>Adding Rcpp settings</div><div>
>> added RcppModules: yada</div><div> >> added Depends: Rcpp</div><div> >> added LinkingTo: Rcpp</div><div> >> added useDynLib directive to NAMESPACE</div><div> >> added Makevars file with Rcpp settings</div>
<div> >> added Makevars.win file with Rcpp settings</div><div> >> added example header file using Rcpp classes</div><div> >> added example src file using Rcpp classes</div><div> >> added example R file calling the C++ example</div>
<div> >> added Rd file for rcpp_hello_world</div><div> >> copied the example module </div><div>R version 2.15.0 (2012-03-30)</div><div>Platform: x86_64-pc-linux-gnu (64-bit)</div><div><br></div><div>locale:</div>
<div> [1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C </div><div> [3] LC_TIME=en_US.UTF-8 LC_COLLATE=en_US.UTF-8 </div><div> [5] LC_MONETARY=en_US.UTF-8 LC_MESSAGES=en_US.UTF-8 </div><div> [7] LC_PAPER=C LC_NAME=C </div>
<div> [9] LC_ADDRESS=C LC_TELEPHONE=C </div><div>[11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C </div><div><br></div><div>attached base packages:</div><div>[1] stats graphics grDevices utils datasets methods base </div>
<div><br></div><div>other attached packages:</div><div>[1] Rcpp_0.9.10</div><div>> </div><div>> </div><div>+ R CMD build rcppapp1</div><div>* checking for file ‘rcppapp1/DESCRIPTION’ ... OK</div><div>* preparing ‘rcppapp1’:</div>
<div>* checking DESCRIPTION meta-information ... OK</div><div>* cleaning src</div><div>* checking for LF line-endings in source and make files</div><div>* checking for empty or unneeded directories</div><div>* building ‘rcppapp1_1.0.tar.gz’</div>
<div><br></div><div>+ R CMD INSTALL rcppapp1</div><div>* installing to library ‘/usr/local/lib/R/site-library’</div><div>* installing *source* package ‘rcppapp1’ ...</div><div>** libs</div><div>g++ -I/usr/share/R/include -DNDEBUG -I"/usr/local/lib/R/site-library/Rcpp/include" -fpic -O3 -pipe -g -c rcpp_hello_world.cpp -o rcpp_hello_world.o</div>
<div>g++ -I/usr/share/R/include -DNDEBUG -I"/usr/local/lib/R/site-library/Rcpp/include" -fpic -O3 -pipe -g -c rcpp_module.cpp -o rcpp_module.o</div><div>g++ -shared -o rcppapp1.so rcpp_hello_world.o rcpp_module.o -L/usr/local/lib/R/site-library/Rcpp/lib -lRcpp -Wl,-rpath,/usr/local/lib/R/site-library/Rcpp/lib -L/usr/lib/R/lib -lR</div>
<div>installing to /usr/local/lib/R/site-library/rcppapp1/libs</div><div>** R</div><div>** preparing package for lazy loading</div><div>** help</div><div>Warning: /home/jq/Desktop/bitbucket/yabbrep/myrstan/rcppapp1/man/rcppapp1-package.Rd:31: All text must be in a section</div>
<div>Warning: /home/jq/Desktop/bitbucket/yabbrep/myrstan/rcppapp1/man/rcppapp1-package.Rd:32: All text must be in a section</div><div>*** installing help indices</div><div>** building package indices</div><div>** testing if installed package can be loaded</div>
<div><br></div><div>* DONE (rcppapp1)</div><div>+ R -q -e 'require(Rcpp);require('\''rcppapp1'\'');m1<-Module('\''yada'\'', '\''rcppapp1'\'');m1$hello()'</div>
<div>> require(Rcpp);require('rcppapp1');m1<-Module('yada', 'rcppapp1');m1$hello()</div><div>Loading required package: Rcpp</div><div>Loading required package: rcppapp1</div><div><br></div><div>
*** caught segfault ***</div><div>address 0x90, cause 'memory not mapped'</div><div><br></div><div>Traceback:</div><div> 1: .Call(symbol)</div><div> 2: Module(module, mustStart = TRUE)</div><div> 3: .getModulePointer(x)</div>
<div> 4: m1$hello</div><div>aborting ...</div><div><br></div></div></div><div><br></div><div>Thanks!</div><div>J</div>