If your question relates to installation please provide the following information:
- Operating System
- RStan Version
- Output of
writeLines(readLines(file.path(Sys.getenv("HOME"), ".R/Makevars")))
- Output of
devtools::session_info("rstan")
If you are reporting a bug (thank you!) please use the issue tracker (github.com/stan-dev/rstan/issues) instead of the forums.
Hi, Iāve used rstan for 4 years successfully under Windows 7. I say this so you wonāt think I am a novice in the use of this great tool. But I also know when I am over my head :-). I am a statistician, not a software professional.
Today I upgraded RStudio to 1.2.1335 and R to 3.6.0 and rstan to 2.18.2.
Now I canāt compile even the 8 schools example. Iām screwed. I get the following ugly message:
āError in compileCode(f, code, language = language, verbose = verbose) :
Compilation ERROR, function(s)/method(s) not created! Error in .shlib_internal(commandArgs(TRUE)) :
C++14 standard requested but CXX14 is not defined
Calls: ā .shlib_internal
Execution halted
In addition: Warning message:
In system(cmd, intern = !verbose) :
running command āC:/PROGRA~1/R/R-36~1.0/bin/x64/R CMD SHLIB file306050bf18a9.cpp 2> file306050bf18a9.cpp.err.txtā had status 1
Error in sink(type = āoutputā) : invalid connectionā
Iāve sought help on line. I see others have a similar problem and seem to have solved it by modifying a makevars.win file. I have no idea what they are doing. Iām afraid this solution is way out of my league. Any advice? Below is the output of the 2 requested codes. Means nothing to me. Please help. Thanks!! Dave
writeLines(readLines(file.path(Sys.getenv(āHOMEā), ā.R/Makevarsā)))
Error in file(con, ārā) : cannot open the connection
In addition: Warning message:
In file(con, ārā) :
cannot open file āC:/Users/Dave/Documents/.R/Makevarsā: No such file or directory
devtools::session_info(ārstanā)
Error in loadNamespace(name) : there is no package called ādevtoolsā
Check out this thread: Problems configuring Makevars.win since R 3.6.0
What worked for me (on Win10) was the following:
- Uninstall rstan package (to be safe) by running the following command in R
remove.packages("rstan")
if (file.exists(".RData")) file.remove(".RData")
- Open (or create) the
Makevars.win
file by running the following command in R
M <- file.path(Sys.getenv("HOME"), ".R", "Makevars.win")
file.edit(M)
- Add the following three lines to the
Makevars.win
file
CXX14=$(BINPREF)g++
CXX14FLAGS=-O3 -march=native -mtune=native
CXX11FLAGS=-O3 -march=native -mtune=native
-
Install RTools 4.0 to the default location (C:/rtools40/
)
https://cloud.r-project.org/bin/windows/testing/rtools40.html
-
Run the following commands in R
Sys.setenv(MAKEFLAGS = paste0("-j", parallel::detectCores()))
install.packages("pkgbuild", INSTALL_opts = "--no-multiarch")
cat("Rtools version 4.0.0", file = file.path("C:", "rtools40", "VERSION.txt"), sep = "\n")
cat("Rtools 4.0", file = file.path("C:", "rtools40", "Rtools.txt"), sep = "\n")
install.packages("rstan", repos = "https://cloud.r-project.org/", dependencies = TRUE, INSTALL_opts = "--no-multiarch")
options(mc.cores = parallel::detectCores())
rstan::rstan_options(auto_write = TRUE)
If you want to install Rtools in a non-default location, you need to update lines 4-5 above.
Good luck and please post again letting us know if this worked or not.
4 Likes
Jeffrey,
Thank you!!! (also thank you to Randall Pruim for his insight and suggestions)
I had already completed your steps 1 and 2, so I just performed the creation of the Makevars.win file using exactly the 3 lines (and only those 3 lines) you recommended. This was easy to do as this file can be created and edited using Windows Notepad text editor and saved in āC:\Users\Dave\Documents.Rā (my user directory). Of course I have absolutely no clue what these 3 lines mean.
I did not perform your steps 4 and 5. From the āgetting startedā page https://github.com/stan-dev/rstan/wiki/RStan-Getting-Started , I get the feeling that with RStudio 1.2.1335 (which I use) Rtools are not needed (am I wrong?).
Now the 8 school example compiles and runs!! J Iām now a Stan forum fan.
FYIā¦ here is what I know about my system:
HP ZBook 15u G2 IntelĀ® Coreā¢ i7-5500U CPU @ 2.40GHz
64-bit OS
Windows 7 Professional Service Pack 1
RStudio Version 1.2.1335
R version 3.6.0
Rstan version 2.18.2
Best regards,
Dave
I followed your directions. Seems better, but still isnāt working: new error message.
Error in compileCode(f, code, language = language, verbose = verbose) :
Compilation ERROR, function(s)/method(s) not created! Warning message:
In system(cmd) : āmakeā not found
In addition: Warning message:
In system(cmd, intern = !verbose) :
running command āC:/PROGRA~1/R/R-3.6.0/bin/x64/R CMD SHLIB file5b645d63a2a.cpp 2> file5b645d63a2a.cpp.err.txtā had status 1
Error in sink(type = āoutputā) : invalid connection