Chapter 13 Appendix D The Windows toolset

If you want to build R or add-on packages from source in Windows, you will need to collect, install and test an extensive set of tools. See for the current locations and other updates to these instructions. (Most Windows users will not need to build add-on packages from source; see Add-on packages for details.)

We have found that the build process for R is quite sensitive to the choice of tools: please follow our instructions exactly, even to the choice of particular versions of the tools.80 The build process for add-on packages is somewhat more forgiving, but we recommend using the exact toolset at first, and only substituting other tools once you are familiar with the process.

This appendix contains a lot of prescriptive comments. They are here as a result of bitter experience. Please do not report problems to the R mailing lists unless you have followed all the prescriptions.

We have collected most of the necessary tools (unfortunately not all, due to license or size limitations) into an executable installer named Rtools*.exe, available from You should download and run it, choosing the default “Package authoring installation” to build add-on packages, or the “full installation” if you intend to build R.

You will need the following items to build R and packages. See the subsections below for detailed descriptions.

  • The command line tools (in Rtools*.exe)
  • The MinGW-w64 32/64-bit toolchain to compile C, Fortran and C++.

For installing simple source packages containing data or R source but no compiled code, none of these are needed.

A complete build of R including PDF manuals, and producing the installer will also need the following:

  • LaTeX
  • The Inno Setup installer
  • (optional) qpdf

It is important to set your PATH properly. The installer Rtools*.exe optionally sets the path to components that it installs.

Your PATH may include . first, then the bin directories of the tools, the compiler toolchain and LaTeX. Do not use filepaths containing spaces: you can always use the short forms (found by dir /x at the Windows command line). Network shares (with paths starting \) are not supported.

For example for a 32-bit build, all on one line,


It is essential that the directory containing the command line tools comes first or second in the path: there are typically like-named tools81 in other directories, and they will not work. The ordering of the other directories is less important, but if in doubt, use the order above.

Our toolset contains copies of Cygwin DLLs that may conflict with other ones on your system if both are in the path at once. The normal recommendation is to delete the older ones; however, at one time we found our tools did not work with a newer version of the Cygwin DLLs, so it may be safest not to have any other version of the Cygwin DLLs in your path.

D.1 LaTeX

The ‘MiKTeX’ ( distribution of LaTeX includes a suitable port of pdftex. This can be set up to install extra packages ‘on the fly’, which is the simplest way to use it (and the default). The ‘basic’ version of ‘MiKTeX’ almost suffices: when last checked packages

epsf inconsolata mptopdf url

needed to be added (on the fly or via the ‘MiKTeX’ Package Manager) to install R. In any case ensure that the inconsolata package is installed—you can check with the ‘MiKTeX’ Package Manager.

The Rtools*.exe installer does not include any version of LaTeX.

It is also possible to use the TeX Live distribution from

Please read Making the manuals about how to make fullrefman.pdf and set the environment variable R_RD4PDF suitably; ensure you have the required fonts installed or that ‘MiKTeX’ is set up to install LaTeX packages on first use.

D.2 The Inno Setup installer

To make the installer package (R-3.4.2-win.exe) we currently require the Unicode version of Inno Setup 5.3.7 or later from This is not included in Rtools*.exe.

Copy file src/gnuwin32/MkRules.dist to src/gnuwin32/MkRules.local and edit it to set ISDIR to the location where Inno Setup was installed.

D.3 The command line tools

This item is installed by the Rtools*.exe installer.

If you choose to install these yourself, you will need suitable versions of at least basename, cat, cmp, comm, cp, cut, date, diff, du, echo, expr, gzip, ls, make, makeinfo, mkdir, mv, rm, rsync, sed, sh, sort, tar, texindex, touch and uniq; we use those from the Cygwin distribution ( or compiled from the sources. You will also need zip and unzip from the Info-ZIP project ( All of these tools are in Rtools*.exe.

Beware: ‘Native’ ports of make are not suitable (including those called ‘MinGW make’ at the MinGW SourceForge site and mingw32-make in some MinGW-w64 distributions). There were also problems with other versions of the Cygwin tools and DLLs. To avoid frustration, please use our tool set, and make sure it is at the front of your path (including before the Windows system directories). If you are using a Windows shell, type PATH at the prompt to find out.

You may need to set the environment variable CYGWIN to a value including ‘nodosfilewarning’ to suppress messages about Windows-style paths.

D.4 The MinGW-w64 toolchain

Technically you need more than just a compiler so the set of tools is referred to as a ‘toolchain’.

The preferred toolchain is part of Rtools*.exe: this uses a version of gcc 4.9.3 and version rt_v3 of the MinGW-w64 project’s runtime.

This toolchain does not use multilib: separate front-ends are used for 32-bit and 64-bit compilation. These compilers need to be specified in BINPREF and BINPREF64 make variables as described previously at the end of Windows packages.

To select a 32-bit or 64-bit build of R, set the options in MkRules.local appropriately (following the comments in the file).

Some external software libraries will need to be re-compiled under the new toolchain: especially those providing a C++ interface. Many of those used by CRAN packages are available from Users developing packages with Rcpp need to ensure that they use a version built with exactly the same toolchain as their package: the recommendation is to build Rcpp from its sources yourself.

There is support for OpenMP and pthreads in this toolchain. As the performance of OpenMP on Windows is poor for small tasks, it is not used for R itself.

D.5 Useful additional programs

The process of making the installer will make use of qpdf to compact some of the package vignettes, if it is available. Windows binaries of qpdf are available from Set the path to the qpdf installation in file MkRules.local.

Developers of packages will find some of the ‘goodies’ at useful.

There is a version of the file command that identifies the type of files, and is used by Rcmd check if available. The binary distribution is included in Rtools*.exe.

The file contains the program xz which can be used to (de)compress files with that form of compression.