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@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel

______________________________________________
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel

Reply via email to