<div dir="ltr"><div><div><div><div>Thanks, Dirk.<br><br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">What exactly do you mean by 1. and 2. ?  Per 'Writing R Extensions' we are<br>
meant to create a tar.gz in either way via 'R CMD BUILD' and then install it<br>
via 'R CMD INSTALL'.<br><br>
Are you doing that?<br></blockquote>
<br></div>Yes. I usually use devtools, but I've done it directly as well.<br><br></div>In #1, for instance: I go to the package source directory, start R, <br></div>do devtools::build and devtools::check. This builds and compiles</div><div>the package. After library() at this point, the module components</div><div>are visible, e.g., LshParameterSetter.</div><div><br></div><div>In #2, for instance, I do devtools::install() or devtools::install_github() or similar.</div><div>Quit R, go to some other directory, restart R, and call library().  The R entry</div><div>points are visible, but none of the module classes.</div><div><br></div><div>I'm unclear as to what in the installation/export process can explain the difference</div><div>between #1 and #2.<br></div><div><br></div><div>Before emailing yesterday, I had tried removing the RCPP_EXPOSED_CLASS()'s, <br></div><div>but then the code does not compile. There is a static_assert error in <br></div><div>wrap_dispatch_unknown_iterable in Rcpp's wrap.h (line 520). I did not see an</div><div>easy way to fix that. (I vaguely recall that I only included them originally because</div><div>I had to.) <br></div><div><br></div><div>I will  look RcppAnnoy and see if I can find a way around using these macros.<br></div><div><br></div><div>Thanks again, Chris</div><div><br></div><br><div><div><div><div><br></div></div></div></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Thu, Nov 9, 2017 at 7:55 AM, Dirk Eddelbuettel <span dir="ltr"><<a href="mailto:edd@debian.org" target="_blank">edd@debian.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span class=""><br>
On 9 November 2017 at 01:54, Christopher Genovese wrote:<br>
| Hello,<br>
|<br>
|   I have a package under development that uses Rcpp modules to expose<br>
| some C++ classes. I hadn't touched the package for some months (close<br>
| to a year). At that time the package compiled and installed without problem<br>
| and worked well. I could access the classes as expected. Recently, having<br>
| updated Rcpp and R in the meantime, I reinstalled the package with<br>
| the following result:<br>
|<br>
|     1. If building and loading from within the package directory, all works<br>
| fine.<br>
|     2. When installing the package, either from github, locally, or<br>
| otherwise,<br>
|         the modules are *not* visible.<br>
<br>
</span>What exactly do you mean by 1. and 2. ?  Per 'Writing R Extensions' we are<br>
meant to create a tar.gz in either way via 'R CMD BUILD' and then install it<br>
via 'R CMD INSTALL'.<br>
<br>
Are you doing that?<br>
<span class=""><br>
| The package passes devtools:check() and compiles fine.<br>
<br>
</span>Well if it passes check you should be fine.<br>
<div><div class="h5"><br>
| For instance, for one of those classes, LshParameterSetter, I do<br>
|<br>
|<br>
| RCPP_EXPOSED_CLASS(<wbr>LshParameterSetter)<br>
|<br>
| RCPP_MODULE(mod_params) {<br>
|     class_<LshParameterSetter>("<wbr>LshParameterSetter")<br>
|<br>
|     .constructor<int,int>()<br>
|<br>
|     .method("withDefaults", &LshParameterSetter::<wbr>withDefaults,<br>
|             "Fill with defaults")<br>
|     .method("distance", &LshParameterSetter::distance,<br>
|             "Set distance metric")<br>
|     .method("numHashFunctions", &LshParameterSetter::<wbr>numHashFunctions,<br>
|             "Set numbers of hash functions and tables")<br>
|     .method("numHashTables",   &LshParameterSetter::<wbr>numHashTables,<br>
|             "Set numbers of hash functions and tables")<br>
|     .method("storage",   &LshParameterSetter::storage,<br>
|             "Set LSH Hash Table Storage type")<br>
|     .method("family",   &LshParameterSetter::family,<br>
|             "Set LSH Family")<br>
|     .method("rotations",   &LshParameterSetter::<wbr>rotations,<br>
|             "Number of rotations")<br>
|     .method("asList",        &LshParameterSetter::asList,<br>
|             "List of parameter values by name")<br>
|    ;<br>
| }<br>
|<br>
| and similarly for the other classes. This module is loaded in the R code<br>
| with<br>
|                      Rcpp::loadModule("mod_params", TRUE)<br>
| and similarly for the other modules.<br>
|<br>
| The installed package has the .rdb, .rdx, and .so file, so it's hard to see<br>
| if something has been lost in the installation.  There's no indication what<br>
| is wrong, but after loading the installed package, a class like<br>
| LshParameterSetter<br>
| is not defined. (Loading from within the package source directory it is,<br>
<br>
</div></div>What do you mean by 'loading from within the package source directory' ?<br>
<span class=""><br>
| showing<br>
|<br>
| > > LshParameterSetter<br>
| > C++ class 'LshParameterSetter' <0x7fde72fb1940><br>
| > Constructors:<br>
| >     LshParameterSetter(int, int)<br>
| ><br>
| > Fields: ...<br>
| ><br>
| as it should be.) I've done this with simple skeletons and not had a<br>
| similar problem. But I don't see a qualitative difference between these<br>
| cases.<br>
|<br>
| The full package code is at  <a href="https://github.com/genovese/falconnr" rel="noreferrer" target="_blank">https://github.com/genovese/<wbr>falconnr</a><br>
| and the session info is below.<br>
<br>
</span>Thanks for posting the link.  Not a small package ...<br>
<span class=""><br>
| I'd appreciate any pointers on this, as the problem is unclear to me,<br>
| especially since it worked without problem last year. I'm happy to<br>
| provide any useful information that I might have omitted here.<br>
<br>
</span>Not sure what is going on there. Package clearly builds. Testing complains<br>
some but hey, it is not a CRAN package yet...<br>
<br>
You have<br>
<br>
    falconnr::LshTable<br>
<br>
visible, but (what you probably want) only un-exported:<br>
<br>
    falconnr:::LshNnTable<br>
    falconnr:::LshParameterSetter<br>
<br>
I have been using Modules for about as long as we've had them, but I have<br>
always been a little mystified by the various UPPERCASE_MACROS exporting<br>
things.  Looking at what was probably my first Modules package, RcppBDT, I<br>
seem to "simply" do<br>
<br>
RCPP_MODULE(bdtDdMod) {<br>
    Rcpp::class_<bdtDd>("bdtDd")<br>
       // ... stuff omitted<br>
<br>
and nothing else for the four or so different modules there.  That worked. I<br>
think you may rely on a helper macro which may have gotten stale as the<br>
_underlying R behaviour_ may have changed.  I think I use one or two of the<br>
exporter macros in other places (ie RcppAnnoy) so you could try that.<br>
<br>
In general, I always recommend to simplify as much as you can.<br>
<br>
Hope this helps,  Dirk<br>
<span class=""><br>
| Thanks for your help, Chris<br>
|<br>
| > sessionInfo()<br>
| R version 3.3.2 (2016-10-31)<br>
| Platform: x86_64-apple-darwin13.4.0 (64-bit)<br>
| Running under: macOS Sierra 10.12.6<br>
|<br>
| locale:<br>
| [1] en_US.UTF-8/en_US.UTF-8/en_US.<wbr>UTF-8/C/en_US.UTF-8/en_US.UTF-<wbr>8<br>
|<br>
| attached base packages:<br>
| [1] grid      stats     graphics  grDevices utils     datasets  methods<br>
| base<br>
|<br>
| other attached packages:<br>
| [1] falconnr_0.0.0.9001 MASS_7.3-45         lattice_0.20-34<br>
|<br>
| loaded via a namespace (and not attached):<br>
| [1] Rcpp_0.12.13     codetools_0.2-15<br>
</span>| ______________________________<wbr>_________________<br>
| Rcpp-devel mailing list<br>
| <a href="mailto:Rcpp-devel@lists.r-forge.r-project.org">Rcpp-devel@lists.r-forge.r-<wbr>project.org</a><br>
| <a href="https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/rcpp-devel" rel="noreferrer" target="_blank">https://lists.r-forge.r-<wbr>project.org/cgi-bin/mailman/<wbr>listinfo/rcpp-devel</a><br>
<span class="HOEnZb"><font color="#888888"><br>
--<br>
<a href="http://dirk.eddelbuettel.com" rel="noreferrer" target="_blank">http://dirk.eddelbuettel.com</a> | @eddelbuettel | <a href="mailto:edd@debian.org">edd@debian.org</a><br>
</font></span></blockquote></div><br></div>