[R] Compiling C-code in Windows

Duncan Murdoch murdoch.duncan at gmail.com
Tue May 31 14:09:19 CEST 2011


On 31/05/2011 7:43 AM, Petar Milin wrote:
> Hello ALL!
> I am an Linux user (Debian testing i386), with very dusty
> Win-experience. Nevertheless, my colleagues and I are making some
> package in R, and I built C-routines to speed up things.
> I followed instruction how to compile C for R (very useful link:
> http://www.stat.lsa.umich.edu/~yizwang/software/maxLinear/noteonR.html,

You should follow the instructions in the R Installation and 
Administration manual to set up the tools on your Windows system.


> and links listed there). Everything works like a charm in Linux. I have
> *.so and wrapper function from R is doing a right call.
> However, I wanted to make *.dll library for Win-users. Now, I used my
> colleague's computer with Win XP on it, and with the latest R. In MS-DOS
> console, I positioned prompt in 'C;\Program Files\R\R-2.13.0\bin\i386\',
> and then I run: 'R CMD SHLIB C:\trial.c'. However, nothing happened, no
> trial.dll, nothing.


Really nothing?  Not even an error message?


Then, I tried with: 'R CMD SHLIB --output=trial.dll
> C:\trial.c', but no luck, again.
> Please, can anyone help me with this? Can I use: 'R CMD SHLIB
> --output=trial.dll C:\trial.c' under Linux, and expecting working DLL?

I assume you mean "under Windows".  I would normally use a forward 
slash, i.e. C:/trial.c; I don't remember if the R CMD code handles 
backslashes.  (It might treat \t as a tab.)  With that change, this 
should work.

One piece of unsolicited advice:  I would hardly ever use R CMD SHLIB. 
Just include the C code in a package, and this is handled automatically 
by R CMD INSTALL.  You won't need the .First.lib if you have a 
useDynLib() statement in your NAMESPACE.

Duncan Murdoch



More information about the R-help mailing list