Compilation error on Windows 10

Summary:

I have used Rstan on Rstudio with my Windows 10 after a week. After some update of packages, i tried to run my previous model (that didn’t have any problem) and now it gives me a problem in the compilation Error. I tried everything, also uninstalling everything of R, Rstudio, but it was useless

Current Output: That’s the error it returns

Error in compileCode(f, code, language = language, verbose = verbose) :
Compilation ERROR, function(s)/method(s) not created! g++.exe: error: base/Documents/R/win-library/3.6/StanHeaders/include/stan/math/prim/mat/fun/Eigen.hpp: No such file or directory
g++.exe: error: base/Documents/R/win-library/3.6/StanHeaders/include: No such file or directory
g++.exe: error: base/Documents/R/win-library/3.6/RcppEigen/include: No such file or directory
make: *** [C:/PROGRA1/R/R-361.2/etc/x64/Makeconf:215: file480c619142e6.o] Error 1

Expected Output:

It hadn’t had any error before, everything was fine.

Current Version:

v2.22.0

I think you just need to do

remove.packages("StanHeaders")
file.remove(".RData")

then restart R and do

install.packages("StanHeaders")

I have tried but the problem still remains

base/Documents/R/win-library/3.6/StanHeaders/include/stan/math/prim/mat/fun/Eigen.hpp

Do you have any idea why the path starts with base? Do you have some non-ASCII characters at the start of the path?

I used a space for that folder, that’s why it wasn’t working. Now i have fixed the problem and there is no more error, thank you very much

Hi - I have the same error. I can find the file that it is looking for in “C:\Program Files\R\R-3.6.0\library\StanHeaders\include\stan\math\prim\mat\fun”. I also have a space in “Program Files”. Unfortunately, I can’t rename the location or change to location of the R folder due to company rules.

I tried reinstalling StanHeaders and it did not help. Any suggestions?

Error in compileCode(f, code, language = language, verbose = verbose) : Compilation ERROR, function(s)/method(s) not created! g++.exe: error: Files/R/R-3.6.0/library/StanHeaders/include/stan/math/prim/mat/fun/Eigen.hpp: No such file or directory g++.exe: error: Files/R/R-3.6.0/library/StanHeaders/include: No such file or directory g++.exe: error: Files/R/R-3.6.0/library/RcppEigen/include: No such file or directory make: *** [C:/PROGRA~1/R/R-36~1.0/etc/x64/Makeconf:215: file18b8644e4c53.o] Error 1 In addition: Warning message: In system(cmd, intern = !verbose) : running command ‘C:/PROGRA~1/R/R-36~1.0/bin/x64/R CMD SHLIB file18b8644e4c53.cpp 2> file18b8644e4c53.cpp.err.txt’ had status 1 Error in sink(type = “output”) : invalid connection

��

Thank you! It worked! :)

I am having this same problem, where the directory path has a space in it.

I tried running
install.packages(c(“rstan”,“StanHeaders”),type=“source”)
as recommended, but am getting an error:
C++14 standard requested but CXX14 is not defined

I ran the code on the RStan Getting Started: Configuration of the C++ Toolchain and have a Makevars.win file in Documents/.R

However, when I run:
Sys.getenv(“R_MAKEVARS_USER”)
it returns an empty string.

How do I tell R where to look for the Makevars.win file?

You can now do

install.packages(c(
"https://win-builder.r-project.org/DZFx7zc08XoW/StanHeaders_2.19.1.zip",
"https://win-builder.r-project.org/z7YZVs4x6LAX/rstan_2.19.3.zip"),
repos = NULL)

without having to mess with the Makevars.win file (which is at ~/.R/Makevars.win). However, in the future if you needed to modify that, there are instructions at

When I try that I get the following warning and error:

Installing packages into ‘C:/Users/Kiva Oken/Documents/R/win-library/3.6’
(as ‘lib’ is unspecified)
trying URL ‘https://win-builder.r-project.org/DZFx7zc08XoW/StanHeaders_2.19.1.zip
Content type ‘application/x-zip-compressed’ length 2260947 bytes (2.2 MB)
downloaded 1.8 MB

Warning in install.packages :
downloaded length 1847296 != reported length 2260947
trying URL ‘https://win-builder.r-project.org/z7YZVs4x6LAX/rstan_2.19.3.zip
Content type ‘application/x-zip-compressed’ length 4781281 bytes (4.6 MB)
downloaded 4.6 MB

Error in install.packages : type == “both” cannot be used with ‘repos = NULL’

Try it with type == "win.binary".

Now I can install the package, but when I try to load the library I get this error:
Loading required package: StanHeaders
Loading required package: ggplot2
Error: package or namespace load failed for ‘rstan’ in inDL(x, as.logical(local), as.logical(now), …):
unable to load shared object ‘C:/Users/Kiva Oken/Documents/R/win-library/3.6/rstan/libs/x64/rstan.dll’:
LoadLibrary failure: The specified procedure could not be found.

Maybe try

remove.packages(c("StanHeaders", "rstan"))
file.remove(".RData")
# restart R
install.packages(c(
"https://win-builder.r-project.org/DZFx7zc08XoW/StanHeaders_2.19.1.zip",
"https://win-builder.r-project.org/z7YZVs4x6LAX/rstan_2.19.3.zip"),
repos = NULL, type = "win.binary")

Unfortunately I still get the same error. There is also a popup box that reads:
The procedure entry point CAR0 could not be located in the dynamic link library C:/Users/Kiva Oken/Documents/R/win-library/3.6/rstan/libs/x64/rstan.dll

(This seems like the same error I get in the RStudio console.)

OK. Try doing

https://github.com/stan-dev/rstan/wiki/Installing-RStan-from-source-on-Windows#configuration

and then

install.packages(c("StanHeaders", "rstan"), type = "source")

Success! Thank you!