[Rcpp-devel] Rcpp, bigmemory, package creation

Alex Ustian alex.l.ustian at gmail.com
Thu Apr 11 19:50:30 CEST 2013


Hello again,

Thank you for looking over my issue and sorry for not giving reproducible
code.  I guess assumed that I was doing something obviously wrong but just
didn't see it.

I did add an entry for bigmemory (and Rcpp) in the DESCRIPTION file for
both the Depends and LinkingTo fields.

Here is an R function and a cpp function that I'm running into the same
problems with when I try to build the package in RStudio with
"build&reload".  Please let me know if there is a better format for me to
put it in.

loopWriterR <- function()  {
  require(bigmemory)

  A <- matrix(0, 6, 1)
  bigA <- as.big.matrix(A)
  print(head(bigA))

  loopWriterCpp(bigA at address)

  head(bigA)
}

// [[Rcpp::depends(bigmemory)]]
#include <Rcpp.h>
#include <bigmemory/MatrixAccessor.hpp>

// [[Rcpp::export]]
void loopWriterCpp(Rcpp::XPtr<BigMatrix> pA)  {
  MatrixAccessor<double> A(*pA);

  for(int i = 0; i < 6; i++)  {
    A[0][i] = i;
  }
}

Here is the output from the build&reload attempt

==> Rcpp::compileAttributes()

bigmemory >= 4.0 is a major revision since 3.1.2; please see package
biganalytics and http://www.bigmemory.org for more information.
==> Rcmd.exe INSTALL --no-multiarch RcppbigmemTest
* installing to library
'C:/Users/Alex/Documents/R/win-library/2.15'g++ -m64
-I"C:/PROGRA~1/R/R-215~1.3/include" -DNDEBUG -I../inst/include
-I"C:/Users/Alex/Documents/R/win-library/2.15/bigmemory/include"
-I"C:/Users/Alex/Documents/R/win-library/2.15/Rcpp/include"
-I"d:/RCompile/CRANpkg/extralibs64/local/include"     -O2 -Wall
-mtune=core2 -c RcppExports.cpp -o RcppExports.o* installing *source*
package 'RcppbigmemTest' ...** libsRcppExports.cpp:9:31: error:
'BigMatrix' was not declared in this scopeRcppExports.cpp:9:40: error:
template argument 1 is invalidRcppExports.cpp:9:40: error: template
argument 2 is invalidRcppExports.cpp: In function 'SEXPREC*
RcppbigmemTest_loopWriterCpp(SEXP)':RcppExports.cpp:13:16: error:
'BigMatrix' was not declared in this scopeRcppExports.cpp:13:25:
error: template argument 1 is invalidRcppExports.cpp:13:25: error:
template argument 2 is invalidRcppExports.cpp:13:30: error: invalid
type in declaration before '=' tokenRcppExports.cpp:13:61: error:
type/value mismatch at argument 1 in template parameter list for
'template<class T, void (* Finalizer)(T*)> class
Rcpp::XPtr'RcppExports.cpp:13:61: error:   expected a type, got
'BigMatrix'RcppExports.cpp:13:61: error: template argument 2 is
invalidRcppExports.cpp:13:71: error: no matching function for call to
'as(SEXPREC*&)'RcppExports.cpp:13:71: note: candidate
is:C:/Users/Alex/Documents/R/win-library/2.15/Rcpp/include/Rcpp/as.h:125:29:
note: template<class T> T Rcpp::as(SEXP)make: *** [RcppExports.o]
Error 1ERROR: compilation failed for package 'RcppbigmemTest'*
removing 'C:/Users/Alex/Documents/R/win-library/2.15/RcppbigmemTest'
Exited with status 1.


// This file was generated by Rcpp::compileAttributes
// Generator token: 10BE3573-1514-4C36-9D1C-5A225CD40393

#include <Rcpp.h>

using namespace Rcpp;

// loopWriterCpp
void loopWriterCpp(Rcpp::XPtr<BigMatrix> pA);
RcppExport SEXP RcppbigmemTest_loopWriterCpp(SEXP pASEXP) {
BEGIN_RCPP
    Rcpp::RNGScope __rngScope;
    Rcpp::XPtr<BigMatrix> pA = Rcpp::as<Rcpp::XPtr<BigMatrix> >(pASEXP);
    loopWriterCpp(pA);
    return R_NilValue;
END_RCPP
}


It seems to me that the automatically generated RcppExports.cpp file needs
to include the bigmemory headers, but it is not.

I also tried putting the bigmemory headers into the package's inst/include
directory and added a flag (PKG_CPPFLAGS += -I../inst/include) for it in
the Makevars files, but this didn't seem to have any effect.

Thanks again for your time,

Alex
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.r-forge.r-project.org/pipermail/rcpp-devel/attachments/20130411/7c6521cd/attachment.html>


More information about the Rcpp-devel mailing list