Buildung R binary packages for Windows with WINE under GNU/Linux

Building Windows binaries of R packages may be tricky. A convenient method is using Uwe Ligges' build service win-builder where you can upload an R source package via FTP, wait for a while and then download the Windows binary from a temporary FTP directory (the link is provided in an email sent to the address specified in the Maintainer field in the DESCRIPTION file of the package). If your package doesn't contain compiled C/C++/Fortran (i.e. only R) code, then you can install the source package (i.e. *.tar.gz file) with install.packages(..., type = "source"). However, you might still need to produce a Windows binary (i.e. *.zip file) in such cases. And maybe you'd like to do that on a GNU/Linux machine. Then then following short tutorial is for you.

First, install the Windows emulator WINE. The following works on openSUSE 11.4 (but can of course be adapted to the distribution of your choice):

Then, download a Windows version of R and install it with WINE (follow the instructions in the graphical installer):

A further prerequisite is a ZIP executable for Windows, e.g. Info-ZIP:

Add the R.exe and zip.exe executables to the Windows (or rather WINE) PATH environment variable for convenience. Open the WINE registry editor and navigate to My Computer > HKEY_CURRENT_USER > Environment. There, create a new string PATH with value C:\Program Files\R\R-2.14.0\bin\i386;C:\Program Files\infozip:

You can check whether PATH is set correctly with the following (just type PATH and hit enter after the WINE terminal has opened):

Now you're ready to build Windows binaries of R packages under GNU/Linux (in case there's no C/C++/Fortran code that needs to be compiled - that would require the setup of an R/Windows development environment, which I haven't tested yet, but see this discussion).
To illustrate, I use Hadley Wickham's extremely useful R package stringr. First, I'll demonstrate how to build the Windows binary with the win-builder. Then, building with WINE is shown.

Get the package source code:

Replace the Maintainer field in the DESCRIPTION file because otherwise Mr. Wickham will receive unrequested email from the win-builder build service:

Next, build the source package (*.tar.gz) and upload it to win-builder. One could do that manually. A nicer way is using Hadley Wickham's devtools package:

Note that the dependency plyr was also installed in the R call above. After a while, check your email for a message by Uwe Ligges (CRAN maintainer for Windows binary packages) and download the Windows binary built by win-builder (note that the follwing URLs are only temporary and probably don't exist anymore):

The procedure using win-builder is convenient, however it involves a number of manual steps and is quite time consuming. Let's see how the same can be achieved with WINE.

Install dependencies for package stringr with the Windows version of R:

Build the binary package with the Windows version of R:

It's that simple once R and the ZIP utility for Windows are set up with WINE.

To finish off, one could compare the Windows binaries produced with win-builder and with WINE:

This entry was posted in R. Bookmark the permalink.

4 Responses to "Buildung R binary packages for Windows with WINE under GNU/Linux"

Leave a reply