-
-
Notifications
You must be signed in to change notification settings - Fork 269
Configuring C Toolchain for Mac
bgoodri edited this page Apr 10, 2024
·
11 revisions
This page contains instructions for configuring your C++ toolchain on a Mac in order to use RStan. We very strongly recommend installing R version 4.0.0 or later. You can then use the macrtools package to setup the necessary C++ toolchain.
Once the toolchain is installed you can then enable some compiler optimizations to improve the estimation speed of the model:
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)
arch <- ifelse(R.version$arch == "aarch64", "arm64", "x86_64")
cat(paste("\nCXX17FLAGS += -O3 -mtune=native -arch", arch, "-ftemplate-depth-256"),
file = M, sep = "\n", append = FALSE)
If you have Catalina or later then you can now go back to install the RStan binary with the instructions at Installation of RStan. Otherwise, see here to install RStan from source.