[Rcpp-devel] Using Rcpp in C++

Dirk Eddelbuettel edd at debian.org
Fri Jun 10 15:20:21 CEST 2011

On 10 June 2011 at 15:06, soeren.vogel at uzh.ch wrote:
| Hello I want to experiment a little with Rcpp, however, as a newby I don't get it to work, e.g.:
| #include <iostream>
| #include <Rcpp.h>
| int main()
| {
|     using namespace Rcpp;
|     RNGScope scope;
|     std::cout << runif( 1, 0, 1) << std::endl;
|     return 0;
| }
| How can I get it to work? Thanks, Sören

This makes no sense.  Without an R instance to bind to, RNGScope has no
purpose as it serves to keep __the R RNG__ in a sane state. No R, no use for

If you want to access R's RNG, look at the Writing R Extensions manual and
the (small but self-contained) R mathlib which gives you that (as well as
distribution functions, but little else).

If you want to combine R and C++ but from the C++ side, take e.g. a look at
RInside.  Which has been discussed here, on my blog, in our talks, etc at
some length.  

So please consinder doing a bit of homework. Google *is* your friend.


Gauss once played himself in a zero-sum game and won $50.
                      -- #11 at http://www.gaussfacts.com

More information about the Rcpp-devel mailing list