# Compilation error on Windows 10

**URL:** <https://discourse.mc-stan.org/t/compilation-error-on-windows-10/12887>\
**Category:** Modeling\
**Created:** [January 30, 2020, 2:56pm UTC](https://discourse.mc-stan.org/t/compilation-error-on-windows-10/12887 "2020-01-30T14:56:06Z")\
**Posts on this page:** 17\
**Page:** 1

<div class="post-metadata">

**Author:** ![LucaBenazzoli](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.mc-stan.org/lucabenazzoli/32/7114_2.png) [@LucaBenazzoli](https://discourse.mc-stan.org/u/LucaBenazzoli)\
**Post date:** [January 30, 2020, 2:56pm UTC](https://discourse.mc-stan.org/t/compilation-error-on-windows-10/12887/1 "2020-01-30T14:56:06Z")

</div>

#### 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:/PROGRA ~~1/R/R-36~~ 1.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

---

<div class="post-metadata">

**Author:** ![bgoodri](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.mc-stan.org/bgoodri/32/4451_2.png) [@bgoodri](https://discourse.mc-stan.org/u/bgoodri)\
**Post date:** [January 30, 2020, 3:40pm UTC](https://discourse.mc-stan.org/t/compilation-error-on-windows-10/12887/2 "2020-01-30T15:40:26Z")

</div>

I think you just need to do

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

```

then restart R and do

```
install.packages("StanHeaders")

```

---

<div class="post-metadata">

**Author:** ![LucaBenazzoli](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.mc-stan.org/lucabenazzoli/32/7114_2.png) [@LucaBenazzoli](https://discourse.mc-stan.org/u/LucaBenazzoli)\
**Post date:** [January 30, 2020, 4:11pm UTC](https://discourse.mc-stan.org/t/compilation-error-on-windows-10/12887/3 "2020-01-30T16:11:17Z")

</div>

I have tried but the problem still remains

---

<div class="post-metadata">

**Author:** ![bgoodri](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.mc-stan.org/bgoodri/32/4451_2.png) [@bgoodri](https://discourse.mc-stan.org/u/bgoodri)\
**Post date:** [January 30, 2020, 4:13pm UTC](https://discourse.mc-stan.org/t/compilation-error-on-windows-10/12887/4 "2020-01-30T16:13:56Z")

</div>

> `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?

---

<div class="post-metadata">

**Author:** ![LucaBenazzoli](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.mc-stan.org/lucabenazzoli/32/7114_2.png) [@LucaBenazzoli](https://discourse.mc-stan.org/u/LucaBenazzoli)\
**Post date:** [January 30, 2020, 4:29pm UTC](https://discourse.mc-stan.org/t/compilation-error-on-windows-10/12887/5 "2020-01-30T16:29:36Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![drang](https://avatars.discourse-cdn.com/v4/letter/d/a4c791/32.png) [@drang](https://discourse.mc-stan.org/u/drang)\
**Post date:** [February 6, 2020, 6:12pm UTC](https://discourse.mc-stan.org/t/compilation-error-on-windows-10/12887/6 "2020-02-06T18:12:11Z")

</div>

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

��

---

<div class="post-metadata">

**Author:** ![bgoodri](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.mc-stan.org/bgoodri/32/4451_2.png) [@bgoodri](https://discourse.mc-stan.org/u/bgoodri)\
**Post date:** [February 7, 2020, 5:02am UTC](https://discourse.mc-stan.org/t/compilation-error-on-windows-10/12887/7 "2020-02-07T05:02:45Z")

</div>

> [@Compilation Error with StanHeaders: no such file or directory](https://discourse.mc-stan.org/t/compilation-error-with-stanheaders-no-such-file-or-directory/13007/2):
>
> This was an issue with the StanHeaders version getting ahead of the RStan version on CRAN, since some of the file paths changed between the two versions. It’s since been reverted but CRAN is still providing the 2.21 binaries. To fix this you need to reinstall the packages from source: install.packages(c("rstan","StanHeaders"),type="source")

---

<div class="post-metadata">

**Author:** ![drang](https://avatars.discourse-cdn.com/v4/letter/d/a4c791/32.png) [@drang](https://discourse.mc-stan.org/u/drang)\
**Post date:** [February 7, 2020, 8:25pm UTC](https://discourse.mc-stan.org/t/compilation-error-on-windows-10/12887/8 "2020-02-07T20:25:37Z")

</div>

Thank you! It worked! :)

---

<div class="post-metadata">

**Author:** ![okenk](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.mc-stan.org/okenk/32/1995_2.png) [@okenk](https://discourse.mc-stan.org/u/okenk)\
**Post date:** [February 12, 2020, 5:05am UTC](https://discourse.mc-stan.org/t/compilation-error-on-windows-10/12887/9 "2020-02-12T05:05:27Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![bgoodri](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.mc-stan.org/bgoodri/32/4451_2.png) [@bgoodri](https://discourse.mc-stan.org/u/bgoodri)\
**Post date:** [February 12, 2020, 5:11am UTC](https://discourse.mc-stan.org/t/compilation-error-on-windows-10/12887/10 "2020-02-12T05:11:50Z")

</div>

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

> **[stan-dev/rstan](https://github.com/stan-dev/rstan/wiki/Installing-RStan-from-source-on-Windows#configuration)**
>
> RStan, the R interface to Stan. Contribute to stan-dev/rstan development by creating an account on GitHub.

---

<div class="post-metadata">

**Author:** ![okenk](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.mc-stan.org/okenk/32/1995_2.png) [@okenk](https://discourse.mc-stan.org/u/okenk)\
**Post date:** [February 12, 2020, 5:31am UTC](https://discourse.mc-stan.org/t/compilation-error-on-windows-10/12887/11 "2020-02-12T05:31:41Z")

</div>

> [@bgoodri](#):
>
> install.packages(c( “[https://win-builder.r-project.org/DZFx7zc08XoW/StanHeaders\_2.19.1.zip](https://win-builder.r-project.org/DZFx7zc08XoW/StanHeaders_2.19.1.zip)”, “[https://win-builder.r-project.org/z7YZVs4x6LAX/rstan\_2.19.3.zip](https://win-builder.r-project.org/z7YZVs4x6LAX/rstan_2.19.3.zip)”), repos = NULL)

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](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](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’

---

<div class="post-metadata">

**Author:** ![bgoodri](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.mc-stan.org/bgoodri/32/4451_2.png) [@bgoodri](https://discourse.mc-stan.org/u/bgoodri)\
**Post date:** [February 12, 2020, 6:28am UTC](https://discourse.mc-stan.org/t/compilation-error-on-windows-10/12887/12 "2020-02-12T06:28:47Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![okenk](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.mc-stan.org/okenk/32/1995_2.png) [@okenk](https://discourse.mc-stan.org/u/okenk)\
**Post date:** [February 12, 2020, 7:07am UTC](https://discourse.mc-stan.org/t/compilation-error-on-windows-10/12887/13 "2020-02-12T07:07:44Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![bgoodri](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.mc-stan.org/bgoodri/32/4451_2.png) [@bgoodri](https://discourse.mc-stan.org/u/bgoodri)\
**Post date:** [February 12, 2020, 7:15am UTC](https://discourse.mc-stan.org/t/compilation-error-on-windows-10/12887/14 "2020-02-12T07:15:28Z")

</div>

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")

```

---

<div class="post-metadata">

**Author:** ![okenk](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.mc-stan.org/okenk/32/1995_2.png) [@okenk](https://discourse.mc-stan.org/u/okenk)\
**Post date:** [February 12, 2020, 7:56pm UTC](https://discourse.mc-stan.org/t/compilation-error-on-windows-10/12887/15 "2020-02-12T19:56:20Z")

</div>

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.)

---

<div class="post-metadata">

**Author:** ![bgoodri](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.mc-stan.org/bgoodri/32/4451_2.png) [@bgoodri](https://discourse.mc-stan.org/u/bgoodri)\
**Post date:** [February 12, 2020, 8:15pm UTC](https://discourse.mc-stan.org/t/compilation-error-on-windows-10/12887/16 "2020-02-12T20:15:18Z")

</div>

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")

```

---

<div class="post-metadata">

**Author:** ![okenk](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.mc-stan.org/okenk/32/1995_2.png) [@okenk](https://discourse.mc-stan.org/u/okenk)\
**Post date:** [February 12, 2020, 8:26pm UTC](https://discourse.mc-stan.org/t/compilation-error-on-windows-10/12887/17 "2020-02-12T20:26:45Z")

</div>

Success! Thank you!
