[Rcpp-devel] Defining template specialisation for wrap on Windows 64bit (Compilation error: 'result_type' does not name a type)

Dirk Eddelbuettel edd at debian.org
Thu Oct 3 15:09:35 CEST 2013


On 3 October 2013 at 14:45, Renaud Gaujoux wrote:
| Thanks Dirk for shooting ideas here :)
| 
| >
| > If you only need the RNGs from R, did you consider using R's standalone Math
| > library?  We can build that fine on Linux, maybe it can be built on Windows?
| > (Not sure anybody would have it ...)
| >
| 
| In short: 1) not needed 2) not wanted
| 
| In long:
| 1) not needed: the RNGs are used in the Octave modules, which build
| fine on both Linux and Windows against the current (not standalone) R
| library.

I understand that. But I fear you are bitten by a side-effect of linking
against the full R on Windows, and linking against a much smaller subset may
give you a better chance at success (conditional on my first hypothesis being
correct, which may be unlikely ;-)

| 2) not wanted: I link against the currently used R library because I
| want to use exactly its RNG, with synchronised seed etc... libRmath
| only provides one kind of RNG, which is not even the default RNG in
| vanilla R (who knows why...) No ways of forcing a particular seed
| (i.e. an RNG kind).

I always confuse myself here but I thought you could get all distributions
and all generators -- see help("RNGkind").

Yes -- Here is a 1-minute mod to the earlier qbeta() example using rnorm()
from R:

edd at max:~/src/progs/C$ cat rmath_rnorm.c
// -*- mode: C++; c-indent-level: 4; c-basic-offset: 4; compile-command: "gcc -s -Wall -O3 -I/usr/share/R/include -o rmath_rnorm rmath_rnorm.c -lRmath -lm" -*-

#include <stdio.h>

#define MATHLIB_STANDALONE 1
#include <Rmath.h>

int main(void) {

    set_seed(123, 456);
    printf("rnorm: %f %f\n", rnorm(0.0, 1.0), rnorm(0.0, 1.0));
    
    return 0;
}
edd at max:~/src/progs/C$ ./rmath_rnorm 
rnorm: -0.334377 -0.293497
edd at max:~/src/progs/C$ ./rmath_rnorm 
rnorm: -0.334377 -0.293497
edd at max:~/src/progs/C$ 


The only thing left is figuring out how to go from R's single-arg set.seed()
to this one.  I think I once looked into this when I connected R's RNGs to
(R)Dieharder a few years back but I can't quite recall what the story was.
 
| I wish I could solve this issue, which is probably linked to some
| strange conflict, since I don't think I use any Linux specific stuff,
| only std. Seemed just a few steps to the cross-platform leap :(

Yes, this needs a Windows expert.

Dirk

-- 
Dirk Eddelbuettel | edd at debian.org | http://dirk.eddelbuettel.com


More information about the Rcpp-devel mailing list