Skip to content
Atif Aziz edited this page Oct 17, 2017 · 1 revision

Prerequisites

  • The build process is currently set up for Linux or Windows. Other platforms are being investigated.
  • A recent version of R. R 3.0 or above is recommended as this is currently used for development and tests.
  • Preferably, set your Path environmental variable to include the path to R.exe (architecture specific) building R packages on windows requires RTools, downloadable for instance from the page R for windows. Information on building R packages on Windows and RTools can be found in http://www.stats.uwo.ca/faculty/murdoch/software/compilingDLLs
  • A recent .NET framework SDK; this document uses the version 4.0. Recent .NET SDK seem to have been bundled with the Windows SDK, for Windows 7 http://www.microsoft.com/en-au/download/details.aspx?id=8279.

Contrary to instructions given in prior versions of this document, cygwin as such is NOT recommended; rely on RTools solely. I have nothing against cygwin, use it, love it, but some very weird stuff was going on on some machines for the rClr build.

Steps

This section was documented from a clean slate If you are sure you have all the prerequisites, you may skip down to the later sections dealing with building rClr itself.

Setup on Windows

Building R packages on Windows can be a difficult endeavour. This section captures the setup performed on a Windows 7 machine, a relatively clean slate. It is reproduced in the hope that this is useful; however blindly following the following screen captures may not lead to a working build environment, depending on the prior setup on your machine, notably depending on the cygwin packges you have and the environment variables you have. Please read the instructions at R for windows.

Installing RTools

Depending on whether you have cygwin already installed or not, you will have a choice to install the cygwin DLL from RTools or not.

rtools_001

rtools_002

rtools_003

rtools_004

rtools_005

You may want to check that the version of gcc used is that of RTools. If building against Microsoft .NET, gcc is currently not used, but if you choose to build against Mono, gcc is the compiler used, and depending on what you have from your cygwin install it may wall be troublesome for the R package compilation.

rtools_006

Installing MiKTeX

For reference if this helps:

miktex001

miktex002

miktex003

Setup on Linux

It is recommended that you set up your R environment such that you can install additional packages to a directory in your home directory, otherwise you will likely need root priviledges. You can set up a .Renviron file in your home directory containing the line R_LIBS=~/R and other potential settings. The practice is drawn from the courses on R package development in http://courses.had.co.nz/11-csiro.

rClr.h:31:62: fatal error: glib-2.0/glib/gtypes.h: No such file or directory
compilation terminated.

installing libgtk2.0 to try to get gtypes.h

Building rClr

Clone the rClr (r2Clr) repository, as per the instructions provided by the Codeplex site.

As of September 2013, the package building process tries to adapt to the local machine as much as feasible.

  • open a windows command prompt (start-run cmd)
  • go to the subdirectory packages, in which you should find the folder for the rClr

005

As of September 2013 the following commands should be enough to build and install:

set R="c:\Program Files\R\R-3.0.1\bin\x64\R.exe"

:: use this to build in debug mode
:: set BuildConfiguration=Debug
:: set MonoBuildConfiguration=MonoInstallDebug

set BuildConfiguration=Release
set MonoBuildConfiguration=MonoInstall

%R% CMD check rClr
%R% CMD REMOVE rClr
%R% CMD INSTALL rClr

The end of a successful build and installation should look like the following screen capture;

003

If for some reasons the paths needed for rClr.props failed to be found, you are likely to meed the following problem:

compile001

A common issue is also that you need to create library files (.lib). The configure script should however have taken care of that.

compile002

You may use the batch file rebuildRlibExports.cmd under the build folder, to facilitate the generation process.

compile003

compile004

A successful build and install:

compile005

Generating the package documentation

The latest version package devtools tries to rebuild the package to document the R functions; however it forces the use of gcc, and overrides the use of Makefile.win. Pending issue.

The package documentation generation currently works on Linux. This is a stop-gap solution.

For reference, current issues with the documentation process on Windows:

compile006

compile007

Building on Windows against Mono

Mono is currently distributed for Windows only as a 32bits application.

Makefile: show how to specify MonoDebugInstall as a target. Explain that it is only 32 bits then.

monowin_001

monowin_002

monowin_003

monowin_004

monowin_005