Re: [R] GetRNGstate() crashes in Windows

From: Prof Brian Ripley <ripley_at_stats.ox.ac.uk>
Date: Tue 28 Jun 2005 - 16:50:50 EST

On Tue, 28 Jun 2005, Ju-Sung Lee wrote:

> I think I've misread the intent of the GetRNGstate() and other API
> functions; these only work when embedded in C functions eventually called
> from R. Apologies for the mistake.

First, the posting guide asks you to send programming questions to the R-devel list.

You can call some of the API functions from a C program, but you need to build a standalone libRmath: see src/nmath/standalone/README in the R sources. But GetRNGstate is not one of them, and `Writing R Extensions' states clearly which they are. See its section `Standalone Mathlib1'.

Linking like

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

is not supported by MinGW (even though it is documented, it fails far too often and the reply to my bug report was that it was not supposed to work!).

> On Tue, 28 Jun 2005, Ju-Sung Lee wrote:
>
>> 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!

-- 
Brian D. Ripley,                  ripley@stats.ox.ac.uk
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford,             Tel:  +44 1865 272861 (self)
1 South Parks Road,                     +44 1865 272866 (PA)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595

______________________________________________
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Received on Tue Jun 28 16:53:51 2005

This archive was generated by hypermail 2.1.8 : Fri 03 Mar 2006 - 03:33:03 EST