[R] The ttest.c example in R under MS Windows

Duncan Murdoch dmurdoch at pair.com
Tue Feb 10 15:00:50 CET 2004


On Tue, 10 Feb 2004 14:27:21 +0100, Lennart.Borgman at astrazeneca.com
wrote :

>We are trying to compile and run the ttest.c example that comes with R (in
>C:\Program Files\R\rw1081\src\library\windlgs\src\ttest.c). After compiling
>it with MS Visual C++ we load the DLL with dyn.load. 
>
>So far it seems good, but when we try to call it from R (after running
>C:\Program Files\R\rw1081\src\library\windlgs\R\windlgs.R) R crashes.
>
>We have tried changing the exports from DLL but have failed so far. Since I
>have a guy helping me who is fluent in MS Visual C++ I believe we are
>missing something crucial. Have anyone compiled and used the example above
>using MS Visual C++? Has anyone done this using the gcc (or Mingw) compiler
>on MS Windows?
>
>I would be very glad to find a complete example for compiling under MS
>Windows.

There's some general information about this sort of thing on my web
page,
<http://www.stats.uwo.ca/faculty/murdoch/software/compilingDLLs/>.

The readme.packages file contains specific instructions about VC++,
but they may be out of date:  I use gcc, and Brian Ripley (who wrote
those instructions) doesn't use Windows as much as he used to.

>From the symptoms ("when we call it R crashes"), my guess would be a
problem with the calling convention, as described on my web page.  You
need to make sure your exports use the C calling convention, not
stdcall.  I don't know how to do that in VC++, but presumably your
fluent helper would.

If you do find what's wrong and it's a case of our documentation being
out of date or incomplete, please write up a description of what works
instead.  This could be incorporated into readme.packages or put up on
my web page.

Duncan Murdoch




More information about the R-help mailing list