Nick
Nick

Reputation: 10499

Load Rcpp module

I have an Studio Rcpp project. One on my file contains the following declarations:

#include <Rcpp.h>
using namespace Rcpp;


int square(int x)
{
  return x*x;
}

RCPP_MODULE(mod_bar) {
  function( "sqaure", &square );
}

I am trying to use the square function by using R after the my library is loaded:

library(myLib)
require(Rcpp)
Module(mod_bar)

But I get the following error message:

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

Upvotes: 1

Views: 323

Answers (2)

Asef
Asef

Reputation: 1

I notice that you are missing // [[Rcpp::export]] before declaration of your function.

Upvotes: 0

Dirk is no longer here
Dirk is no longer here

Reputation: 368261

Take an existing package with Rcpp Modules and compare.

Maybe you just need a loadModules("mod_bar"), maybe you need something else. We can't tell from here.

Every full regression test for Rcpp includes building and the embedded testRcppModule package containing a module. I would start to compare to this one.

Upvotes: 1

Related Questions