-
-
Notifications
You must be signed in to change notification settings - Fork 266
Configuring C Toolchain for Mac
Andrew Johnson edited this page Nov 27, 2020
·
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. Use the macOS R toolchain installer to setup the C++ toolchain. If you have Catalina or a later version of the Mac operating system, then you may need to open it by pressing CTRL+right-click and then clicking Open in order to bypass the security settings that took effect on Macs with Catalina on January 1, 2020.
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)
cat("\nCXX14FLAGS += -O3 -mtune=native -arch x86_64 -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.