[R] GetRNGstate() crashes in Windows

Ju-Sung Lee jusung at andrew.cmu.edu
Tue Jun 28 07:07:48 CEST 2005


Hi,

Has anyone managed to successfully call GetRNGstate() / PutRNGstate() 
without crashing in a Windows environment (spec. XP)?  I've compiled 
successfully using both the latest Cygwin, latest Mingw, and the version 
of Mingw suggested in "Building R for Windows" website, but when the 
executable runs, it crashes; the functions themselves can run when I omit 
GenRNGstate()/PutRNGstate, but return the same values every time.  My 
compilation command is, having copied R.dll to my current directory:

gcc -o prog.exe prog.c -I{R's include path} R.dll

I've also tried:

gcc -o prog.exe prog.c -I{R's include path} -L./ -lR

I've managed to successfully compile Rmath.dll and call R functions that 
way, but remain puzzled why the first way doesn't work.  I've read mention 
of "initializing" R (within a C program I assume) but haven't found the 
documentation that explains this.

My test program is simply:
#include <R.h>
int main() {
   GetRNGstate();
   PutRNGstate();
   return 0;
}

I've also tried #include-ing host of the other .h files.   Thanks!

Juice




More information about the R-help mailing list