Thank you!
Just in case the link breaks in the future, here’s the relevant section of code to be run from R after having installed Rtools but before installing rstan:
dotR <- file.path(Sys.getenv("HOME"), ".R")
if (!file.exists(dotR)) dir.create(dotR)
M <- file.path(dotR, "Makevars.win")
if (!file.exists(M)) file.create(M)
cat("\nCXX14FLAGS=-O3 -march=native",
"CXX14 = g++ -m$(WIN) -std=c++1y",
"CXX11FLAGS=-O3 -march=native",
file = M, sep = "\n", append = TRUE)
In my particular case, I also had to edit this line
"CXX14 = g++ -m$(WIN) -std=c++1y"
and replace g++
with the full path C:/Rtools/mingw_64/g++.exe