[R] Load the shared object/DLL

Guohui Ding
Wed, 16 Apr 2008 10:28:48 -0000

Dear All,

I have written a function in c (in a file named 'a.c') as follows,

void convolve(double *a, int *na, double *b, int *nb, double *ab)
{
 int i, j, nab = *na + *nb - 1;

 for(i = 0; i < nab; i++)
    ab[i] = 0.0;
 for(i = 0; i < *na; i++)
    for(j = 0; j < *nb; j++)
       ab[i + j] += a[i] * b[j];
}

Then, I created a shared file in the Windows,

 R CMD SHLIB -d -o a.dll a.c

Every thing is OK now.

I changed the working directory of the R environment to the directory
containing the a.dll.
I enter two commands in the R console,

> dyn.load("a.dll")
> is.loaded("a")
[1] FALSE

The question is that, why was the "a.dll" failed to be loaded in the R
enviroment? Which step resuted in this problem?

Any suggestion was welcome.

G. Ding

	[[alternative HTML version deleted]]