[R] Problem with rcmd SHLIB

Duncan Murdoch murdoch at stats.uwo.ca
Thu Mar 11 17:03:54 CET 2010

On 11/03/2010 10:57 AM, denise xifaras wrote:
> Hi all,
> I am trying to call a C function from R (version 2.10.1) on a windows machine.
> The C code is in a .c file, I have pasted the code below although I'm very confident that it does not contain any errors (it is not my code), but also, the problem that I have occurs with every .c file that I have tried this with.
> I have installed Rtools and included: 
> C:\Rtools\bin; C:\Rtools\perl; C:\Rtools\MinGW\bin;"C:\Program 
> Files\R\R-2.10.1\bin"
> in my path from My Computer.

That is not sufficient:  those need to be first, not just "included".   
There are often other versions of make or find or the other tools 
installed on Windows systems.
> I would like to create a .dll file in order to load it in R and call the C function.
> In the command prompt I type:
> rcmd SHLIB C:\...\filename.c     (or R CMD SHLIB C:\...\filename.c)
> and I get the message:
> make: nothing to be done for 'all'

I would recommend switching to that directory, then using Rcmd SHLIB 
filename.c.  Windows pathnames sometimes have spaces in them which can 
mess up the tools.

Duncan Murdoch
> I understand that this message means that the particular file has already been compiled and no changes have been made and so the .dll file must already exist. The problem is that this hasn't happened. I have never compiled a .c file this way on this computer and there definitely aren't any .dll files as compiling hasn't ever actually worked.
> Any ideas about why this is happening?
> Thank you all in advance for the help and any feedback,
> Best,
> Denise
> C code:
> void convolve1(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];
> }
> 	[[alternative HTML version deleted]]
> ------------------------------------------------------------------------
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.

More information about the R-help mailing list