Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Configuring C Toolchain for Linux

bgoodri edited this pageApr 10, 2024 ·6 revisions

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.

Ubuntu LTS (16.04, 18.04, 20.04)

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-rstan

Ubuntu Non-LTS

Non-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-dev

Then in R, install the package:

Sys.setenv(DOWNLOAD_STATIC_LIBV8 = 1)install.packages("rstan")

Debian Testing

Debian users of DebianTesting can use

apt-get install r-cran-rstan

C++ toolchain configuration

The 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.

Clone this wiki locally


[8]ページ先頭

©2009-2025 Movatter.jp