<div dir="ltr"><div>I think the problem was because the user's module was not loaded in zzz.R file, and after I added my own module name manually. It works !.  However, I would like to know what is the correct way to do it.  When I created the package, I provided the c++ file of my own as below, is there anyway the custom module can be added after creating the skeleton package if I provided a source cpp file.  Also if there are more classes and modules in different .cpp files, should I just have to manually add each of them into the zzz.R file ?</div>
<div> </div><div>> library(Rcpp)<br>> Rcpp.package.skeleton(name="testModule1", cpp_files="./test_module.cpp", module=TRUE)<br>Creating directories ...<br>Creating DESCRIPTION ...<br>Creating NAMESPACE ...<br>
Creating Read-and-delete-me ...<br>Saving functions and data ...<br>Making help files ...<br>Done.<br>Further steps are described in './testModule1/Read-and-delete-me'.</div><div>Adding Rcpp settings<br> >> added RcppModules: yada, stdVector, NumEx<br>
 >> added Imports: Rcpp<br> >> added LinkingTo: Rcpp<br> >> added useDynLib directive to NAMESPACE<br> >> added importFrom(Rcpp, loadModule) directive to NAMESPACE<br> >> added importFrom(Rcpp, evalCpp) directive to NAMESPACE<br>
 >> copied /people/d3j508/Wyoming/test_module.cpp to src directory<br> >> added example src file using Rcpp attributes<br> >> compiled Rcpp attributes<br> >> added Rd file for rcpp_hello_world<br> >> copied the example module file </div>
<div> </div><div>Thanks a lot.</div><div>Chaomei<br></div><div class="gmail_quote">---------- Forwarded message ----------<br>
From: <b class="gmail_sendername">Chaomei Lo</b> <span dir="ltr"><<a href="mailto:chaomeilo@gmail.com" target="_blank">chaomeilo@gmail.com</a>></span><br>Date: Tue, Jul 1, 2014 at 11:29 PM<br>Subject: package contains overloaded methods in module<br>

To: <a href="mailto:rcpp-devel@lists.r-forge.r-project.org" target="_blank">rcpp-devel@lists.r-forge.r-project.org</a><br><br><br><div dir="ltr"><div>I use Romain's example as follows (after /// line).  It works fine with the sourceCpp(..). However, with the package I created, it loaded fine but I got this error below when I instantiate the class. -Thanks for help.</div>


<div><br></div><div> > library("testModule", lib.loc="/people/me/.Rlibs")</div><div>> r <- new( Randomizer )</div><div>Error in .getClassFromCache(Class, where) : object 'Randomizer' not found</div>


<div><br></div><div>////////////////////////////////////////////////////////</div><div>#include <Rcpp.h></div><div><br></div><div>using namespace Rcpp;</div><div><br></div><div>class Randomizer {</div><div>public:</div>


<div><br></div><div>     Randomizer(){}</div><div><br></div><div>        NumericVector get( int n ){</div><div>                RNGScope scope ;</div><div>                return runif( n, 0.0, 1.0 );</div><div>        }</div>


<div><br></div><div>        NumericVector get( int n, double min ){</div><div>                RNGScope scope ;</div><div>                return runif( n, min, 1.0 );</div><div>        }</div><div><br></div><div>        NumericVector get( int n, double min, double max ){</div>


<div>                RNGScope scope ;</div><div>                return runif( n, min, max );</div><div>        }</div><div><br></div><div>} ;</div><div><br></div><div><br></div><div>RCPP_MODULE(mod){</div><div><br></div>

<div>
     // helping the compiler disambiguate things</div><div>     NumericVector (Randomizer::*get_1)(int) = &Randomizer::get ;</div><div>     NumericVector (Randomizer::*get_2)(int,double) = &Randomizer::get ;</div>


<div>     NumericVector (Randomizer::*get_3)(int,double,double) =</div><div>&Randomizer::get ;</div><div><br></div><div>        class_<Randomizer>( "Randomizer" )</div><div><br></div><div>            .default_constructor()</div>


<div><br></div><div>                .method( "get" , get_1 )</div><div>                .method( "get" , get_2 )</div><div>                .method( "get" , get_3 )</div><div>                ;</div>


<div><br></div><div><br></div><div>}</div></div>
</div><br></div>