Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork271
Configuring C Toolchain for Linux
This page contains instructions for configuring your C++ toolchain on Linux in order to use RStan.
Using RStan requires eitherg++ version 4.9 and up orclang++ version 3.4 and up as they support the C++14 standard. Such a compiler is almost always available and is likely already installed system wide but may not be the default compiler on older systems such as RHEL7.
It is possible to install a packaged (pre-built) RStan binary from your distribution's repositories.
Ubuntu LTS users on R>=4.0 can install a binary version of RStan with
# Add Michael Rutter's c2d4u4.0 PPA (and rrutter4.0 for CRAN builds too)sudo add-apt-repository ppa:marutter/rrutter4.0sudo add-apt-repository ppa:c2d4u.team/c2d4u4.0+sudo apt updatesudo apt install r-cran-rstanNon-LTS users will need to install the R packages from source. First, the required system packages need to be installed:
sudo apt-get install r-base r-base-dev libcurl4-openssl-devThen in R, install the package:
Sys.setenv(DOWNLOAD_STATIC_LIBV8 = 1)install.packages("rstan")Debian users of DebianTesting can use
apt-get install r-cran-rstanThe following will create or edit a configuration file for the C++ toolchain
dotR<- file.path(Sys.getenv("HOME"),".R")if (!file.exists(dotR)) dir.create(dotR)M<- file.path(dotR,"Makevars")if (!file.exists(M)) file.create(M)cat("\nCXX17FLAGS=-O3 -march=native -mtune=native -fPIC","CXX17=g++",# or clang++ but you may need a version postfixfile=M,sep="\n",append=TRUE)
Note that your compiler may have a version number postfix, such asg++-7 orclang++-6.0.
As of version 2.21, RStan depends on theV8 R package. For Linux, this means that you need to have thelibv8 library installed on your system. There are instructions for installing this library on a variety of distributions on theV8 Github:https://github.com/jeroen/V8#getting-started.
If, however, you are not able to install thelibv8 library on your particular system, you can request that a static build be downloaded during the R package installation. This is done via:
Sys.setenv(DOWNLOAD_STATIC_LIBV8 = 1)install.packages("V8")At this point, you can proceed toHow to Use RStan if you have installed the binary version of it or otherwisebuild it from source.