[Rcpp-devel] Sugar/inline and RTools

Wray, Christopher christopher.wray.10 at ucl.ac.uk
Sun Dec 12 16:03:57 CET 2010

Im using windows7, R2.12, Rtools2.12 and all the latest packages of inline, rcpp, etc. Over the last few weeks I have managed to get loads of the examples working, and all makes sense and is pretty clear. I had a couple of questions/comments:

1. RTools: On windows, I understand that Rcpp and R depend in a critical way upon RTools. I have recently been rewriting some parallelized C++ code that uses omp.h and the RcppAramdillo plugin. Im also a fan of running code snippits using inline, etc. RTools does not provide full suport for omp (no real surprise given the "minimum"GW distribution). So I had to add libpthreads, etc, to my RTools installation (libgomp is already included) and use "cppargs= -fopenmp" and "libargs = -lgomp -lpthread" when using "cfunction" from inline. All works fine though. Is it *only* the core R build process that determines what RTools toolchain contains? Could this change with more usage of Rcpp (on windows)? Duncan Murdoch who maintains RTools pointed me in the right direction, to find this solution.

2. As far as I can tell the "cxxfunction" does not allow the passing of *additional* PKG_CPPFLAGS and PKG_LIBS args explictly (these are set from "env <- settings$env" with "do.call(Sys.setenv, env)" if a plugin is used). Is there a cleaner way of passing compiler options/flags when using cxxfunction + plugin? I do appreciate that plugins circumvent the need for such compiler options, etc, and so I guess this is somewhat of a pathological example. Right now, I'm using my own hacked version of cxxfunction to pass the additional flags (in 1.) to get parallel code to compile (on windows).

3. Rcpp::sugar. I have been trying to replicate this R snippet using sugar, but have not had much luck:
R> sapply(rep(3,100), runif)
This returns a column major matrix of size 3x10.

I tried (column assigment):

int N = as<int>(nn); //N=3
NumericMatrix hrcc;
for(int k=0; k<100; k++){
 hrcc(_,k) = sapply(N, runif);}

But the compiler complains about runif being overloaded and not resolved. I have checked for examples and docs and looked at the sugar unit tests also. Am I doing something stupid? Do I need to specify runif more carefully? Am I using or assiging NumericMatrix incorrectly?

Many thanks, chris

More information about the Rcpp-devel mailing list