Chapter 2 Installation

Before developing with Rcpp, you need to install a C++ compiler.

2.1 Install C++ compiler

2.1.1 Windows

Install Rtools.

2.1.2 Mac

Install Xcode command line tools. Execute the command xcode-select --install on Terminal.

2.1.3 Linux

Install gcc and related packages.

In Ubuntu Linux, execute the command sudo apt-get install r-base-dev on Terminal.

2.2 Using other compilers installed by yourself

If you installed other compiler (g++, clang++) different from above, create the following file under the user’s home directory. Then set environment variables in the file.

Linux, Mac

  • .R/Makevars

Windows

  • .R/Makevars.win

Example settings of environmental variables

CC=/opt/local/bin/gcc-mp-4.7
CXX=/opt/local/bin/g++-mp-4.7
CPLUS_INCLUDE_PATH=/opt/local/include:$CPLUS_INCLUDE_PATH
LD_LIBRARY_PATH=/opt/local/lib:$LD_LIBRARY_PATH
CXXFLAGS= -g0 -O2 -Wall
MAKE=make -j4

2.3 Install Rcpp

You can install Rcpp by executing the following code.

install.packages("Rcpp")