Hi.  I would like to start using Rcpp modules in my code, but I am having some 
trouble loading them into R.  Here is an example:

#include <Rcpp.h>

template<typename T>
class adding {

 public:
  const T a, b;
  adding(const T&, const T&);
  T add2();

};

template<typename T>
adding<T>::adding(const T& a_, const T& b_) : a(a_), b(b_) {}

template<typename T>
T adding<T>::add2() {

  T res = a + b;
  return(res);
}

RCPP_MODULE(adding){

  Rcpp::class_< adding<double> >("adding")
    .constructor<double, double>()
    .method("add2",&adding<double>::add2)
    ;
}


Then, in R, I do this:

library(Rcpp)
dyn.load("add.so")
mod <- Module("adding")
mod

The result is:

Uninitialized module named "adding" from package ".GlobalEnv"


I also tried adding a PACKAGE argument, such as PACKAGE = "add.so", to no 
avail.  So I am wondering if it is possible to use Rcpp modules with 
self-compiled code, outside of the R package structure (I believe I have good 
reasons for doing this).  The library may also include other C++ functions that 
are loaded with no problem.  It's just the module that is not recognized.

Thanks in advance for any suggestions.

Michael





-------------------------------------------
Michael Braun
Associate Professor of Management Science
MIT Sloan School of Management
100 Main St.., E62-535
Cambridge, MA 02139
braunm at mit.edu





Attachment: smime.p7s
Description: S/MIME cryptographic signature

_______________________________________________
Rcpp-devel mailing list
Rcpp-devel@lists.r-forge.r-project.org
https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/rcpp-devel

Reply via email to