[Rcpp-devel] pass an arma::mat& to a exported function in a package

riadh zaatour zaatour_riadh at yahoo.fr
Wed Dec 11 19:53:34 CET 2013


Hello,
I have a code looking like this :

#include <RcppArmadillo.h>
// [[Rcpp::depends(RcppArmadillo)]]
using namespace Rcpp;

// [[Rcpp::export]]
void func1(arma::mat& a) {
    ....
}
this compiles and executes fine when used with sourceCpp().

Then I include this code in a package, I call compileAttributes(), then I build and install my package and all that works fine.
Then, in R :
a=matrix(c(0,1,1,0),ncol=2,byrow=TRUE)
func1(a)
does not work and I receive the message
Error in .Call("pkgname_func1", PACKAGE = "pkgname", a,  :  "pkgname_func1" not available for .Call() for package "pkgname"


If I put SEXP instead of arma::mat& as a parameter type in the exported function, all work fine.

Have I missed something for that to work with sourceCpp() and fail when within a package?

Thanks a lot
Riadh
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.r-forge.r-project.org/pipermail/rcpp-devel/attachments/20131211/4789fec5/attachment.html>


More information about the Rcpp-devel mailing list