Installing RStan on Windows10

I’m running the latest versions of R and Rstudio and attempting to install RStan with the Windows 10 environment. I’ve followed the steps available in the RStan documentation, but I’m getting the following error when running the example model:

Compilation ERROR, function(s)/method(s) not created!
Error in compileCode(f, code, language = language, verbose = verbose) :
sh: C:/RBuildTools/4.0/usr/mingw_64/bin/g++: No such file or directorymake: *** [C:/Users/wetherij/ONEDRI~1/DOCUME~1/R/R-40~1.4/etc/x64/Makeconf:229: file3aac10963d7.o] Error 127
In addition: Warning messages:
1: package ‘rstan’ was built under R version 4.0.5
2: package ‘StanHeaders’ was built under R version 4.0.5
3: In system(paste(CXX, ARGS), ignore.stdout = TRUE, ignore.stderr = TRUE) :
‘C:/rtools40/usr/mingw_/bin/g++’ not found

Any advice you can provide would be greatly appreciated. Thanks in advance.

Can you post the output from the following:

Sys.getenv("BINPREF")
readLines("~/.Rprofile")