From simon.urbanek at r-project.org  Tue Mar 17 14:04:59 2009
From: simon.urbanek at r-project.org (Simon Urbanek)
Date: Tue, 17 Mar 2009 09:04:59 -0400
Subject: [Rd] R freeze when loading dll with dyn.load
In-Reply-To: <903318.56099.qm@web24715.mail.ird.yahoo.com>
References: <903318.56099.qm@web24715.mail.ird.yahoo.com>
Message-ID: <CF9C4DF9-FD71-4EE0-A641-AC40892BF94B@r-project.org>


On Mar 17, 2009, at 8:24 , Morel Didier wrote:

> Good morning,
>
> I am investigating dll import in R under Windows XP. Using examples  
> I found on the internet, I started with a very simple dll, e.g.  
> including only the basic function:
>
> void
> {
> *x2 = x*x;
> }sqr(doublex, double*x2)
>

This is not a valid C code. What you may have possibly meant is

void sqr(double *x, double *x2) {
  *x2 = *x * *x;
}

 > dyn.load("tt.dll")
 > .C("sqr",4,0)
[[1]]
[1] 4

[[2]]
[1] 16

Cheers,
S


> I compiled it as a dll with Eclipse and Cygwin's gcc.

You should be using MinGW - I don't think anything else is directly  
supported (see R Windows FAQ).

Cheers,
S


> It works when I call it with another simple .exe C program, compile  
> with Eclipse and gcc as well. I can do what I want with x2 after I  
> have called the function.
>
> However, R freezes when I try to load it with the following command:
>
> dyn.load('c:/.../sqr/Release/sqr.dll')
>
> I know the path I provide is correct, it's the same without the .dll  
> extension and providing an invalid path makes the function returning  
> an error message (LoadLibrary failure...) but not freeze. Has anyone  
> an idea of what is happening?
>
> Thanks for your help,
> Best regards,
> Didier.
>
>
>
> 	[[alternative HTML version deleted]]
>
> ______________________________________________
> R-devel at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel



[Rd] R freeze when loading dll with dyn.load
Simon Urbanek