Skip to content
Prev 2484 / 10988 Next

[Rcpp-devel] Using Rcpp in C++

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
RNGScope.

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.

Dirk