The command-line build environment is where Rtools supplies compilers and build utilities for R packages. Rtools is a Windows toolchain that lets R compile package code written in languages such as C and C++.
Building packages from source
R can install many packages as prebuilt binaries, but a source package with compiled code needs a suitable toolchain. Rtools provides compilers and supporting utilities so R can build that code on Windows.
The tools work behind familiar R commands. For example, R CMD INSTALL can compile and install a package from source, while R CMD build and R CMD check are used in package preparation and testing. Package developers can use these workflows to build and check their own packages as well as install packages that need compilation.
What does Rtools provide?
The toolchain includes compilers for native package code and utilities such as make, which coordinates build steps. These components are called by R during package tasks; Rtools does not provide a separate statistical programming interface.
- Compile package code written in C or C++.
- Run build steps required by source packages.
- Support package build and check workflows.
Using the toolchain with R
R package commands invoke the build tools when a task requires compilation. This means Rtools is most relevant when installing a source package that contains compiled code or developing a package with native code. The package's R code and build files determine which tools are needed; Rtools supplies the Windows-side toolchain those tasks call.
Pros
- Compilers support packages with native code
- Works with R package build, install, and check workflows
- Includes build utilities such as make
System requirements: Windows 10, Windows 11 · ARM64 and x64 · Rtools45 installer: approximately 450 MB; approximately 3 GB after installation
What is Rtools used for?
It supplies compilers and build utilities for building R packages from source on Windows.
Do all R packages need Rtools?
No. It is needed for tasks that compile package source code, such as building packages with native code.
How does R use Rtools?
R invokes its tools during commands such as R CMD INSTALL, R CMD build, and R CMD check when compilation or build steps are required.