# Modeling failed Warnings: 'C:/Users/R-34~1.3/rtools40/usr/mingw\_/bin/g++' not found Errors: Multiple results for CXX14FLAGS found, something is wrong.FALSE

**URL:** <https://discourse.mc-stan.org/t/modeling-failed-warnings-c-users-r-34-1-3-rtools40-usr-mingw-bin-g-not-found-errors-multiple-results-for-cxx14flags-found-something-is-wrong-false/19154>\
**Category:** RStan\
**Tags:** installation, rstan\
**Created:** [November 8, 2020, 11:54pm UTC](https://discourse.mc-stan.org/t/modeling-failed-warnings-c-users-r-34-1-3-rtools40-usr-mingw-bin-g-not-found-errors-multiple-results-for-cxx14flags-found-something-is-wrong-false/19154 "2020-11-08T23:54:50Z")\
**Posts on this page:** 20\
**Page:** 3

<div class="post-metadata">

**Author:** ![ASaeed](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.mc-stan.org/asaeed/32/9589_2.png) [@ASaeed](https://discourse.mc-stan.org/u/ASaeed)\
**Post date:** [November 10, 2020, 9:58am UTC](https://discourse.mc-stan.org/t/modeling-failed-warnings-c-users-r-34-1-3-rtools40-usr-mingw-bin-g-not-found-errors-multiple-results-for-cxx14flags-found-something-is-wrong-false/19154/41 "2020-11-10T09:58:39Z")

</div>

The output is still huge… I am just copying the last few lines again.

In file included from \server/userhome/students4/My Documents/R/win-library/4.0/StanHeaders/include/stan/math/rev/core.hpp:46,  
from ./stan/model/model\_base.hpp:5,  
from …/inst/include/rstan\_next/stan\_fit.hpp:7,  
from stan\_fit.cpp:1:  
\server/userhome/students4/My Documents/R/win-library/4.0/StanHeaders/include/stan/math/rev/core/set\_zero\_all\_adjoints.hpp: At global scope:  
\server/userhome/students4/My Documents/R/win-library/4.0/StanHeaders/include/stan/math/rev/core/set\_zero\_all\_adjoints.hpp:14:13: warning: ‘void stan::math::set\_zero\_all\_adjoints()’ defined but not used [-Wunused-function]  
static void set\_zero\_all\_adjoints() {  
^ ~~~~~~~~~~~~~~~~~~~~  
C:/Users/R-3.4.3/rtools40/mingw32/bin/ar -rs …/inst/lib//i386/libStanServices.a stan\_fit.o stan\_fit\_base.o  
C:\Users\R-3.4.3\rtools40\mingw32\bin\ar.exe: creating …/inst/lib//i386/libStanServices.a  
no DLL was created  
ERROR: compilation failed for package ‘rstan’

- removing ‘\server/userhome/students4/My Documents/R/win-library/4.0/rstan’  
Warning in install.packages :  
installation of package ‘rstan’ had non-zero exit status

---

<div class="post-metadata">

**Author:** ![andrjohns](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.mc-stan.org/andrjohns/32/15297_2.png) [@andrjohns](https://discourse.mc-stan.org/u/andrjohns)\
**Post date:** [November 10, 2020, 10:32am UTC](https://discourse.mc-stan.org/t/modeling-failed-warnings-c-users-r-34-1-3-rtools40-usr-mingw-bin-g-not-found-errors-multiple-results-for-cxx14flags-found-something-is-wrong-false/19154/42 "2020-11-10T10:32:20Z")

</div>

This is certainly being much trickier than usual, sorry about all this!

First, we can cut down the output a bit more by adding `-Wno-unused-function` to `Makevars.win` file, in the same way you did before.

Next, I’ll get you to remove the StanHeaders package: `remove.packages("StanHeaders")`, and restart R.

Let’s double check that you can compile c++ from R. Can you post the output from:

```
system("touch foo.cpp")
system("R CMD SHLIB foo.cpp")

```

---

<div class="post-metadata">

**Author:** ![ASaeed](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.mc-stan.org/asaeed/32/9589_2.png) [@ASaeed](https://discourse.mc-stan.org/u/ASaeed)\
**Post date:** [November 10, 2020, 11:18am UTC](https://discourse.mc-stan.org/t/modeling-failed-warnings-c-users-r-34-1-3-rtools40-usr-mingw-bin-g-not-found-errors-multiple-results-for-cxx14flags-found-something-is-wrong-false/19154/43 "2020-11-10T11:18:17Z")

</div>

> system(“touch foo.cpp”)  
> [1] 0  
> system(“R CMD SHLIB foo.cpp”)  
> C:/Users/R-3.4.3/rtools40/mingw64/bin/g++ -std=gnu++11 -I"C:/Users/R/R-40~1.3/include" -DNDEBUG -O2 -Wall -mfpmath=sse -msse2 -mstackrealign -c foo.cpp -o foo.o  
> C:/Users/R-3.4.3/rtools40/mingw64/bin/g++ -std=gnu++11 -shared -s -static-libgcc -o foo.dll tmp.def foo.o -LC:/Users/R/R-40~1.3/bin/x64 -lR  
> [1] 0

---

<div class="post-metadata">

**Author:** ![andrjohns](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.mc-stan.org/andrjohns/32/15297_2.png) [@andrjohns](https://discourse.mc-stan.org/u/andrjohns)\
**Post date:** [November 10, 2020, 11:21am UTC](https://discourse.mc-stan.org/t/modeling-failed-warnings-c-users-r-34-1-3-rtools40-usr-mingw-bin-g-not-found-errors-multiple-results-for-cxx14flags-found-something-is-wrong-false/19154/44 "2020-11-10T11:21:02Z")

</div>

Great! So it’s compiling C and C++ without issue, so it’s not a toolchain issue. For now, can you just install RStan regularly (not from source), and then try the example model:

```
install.packages("rstan")
library(rstan)
example(stan_model,run.dontrun=T)

```

---

<div class="post-metadata">

**Author:** ![ASaeed](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.mc-stan.org/asaeed/32/9589_2.png) [@ASaeed](https://discourse.mc-stan.org/u/ASaeed)\
**Post date:** [November 10, 2020, 11:27am UTC](https://discourse.mc-stan.org/t/modeling-failed-warnings-c-users-r-34-1-3-rtools40-usr-mingw-bin-g-not-found-errors-multiple-results-for-cxx14flags-found-something-is-wrong-false/19154/45 "2020-11-10T11:27:05Z")

</div>

Good news rstan and stan headers got installed with no errors. But the example gave the following error.

> [@andrjohns](#):
>
> ```no-highlight
> install.packages("rstan")
> library(rstan)
> example(stan_model,run.dontrun=T)
> 
> ```

```no-highlight
Compilation ERROR, function(s)/method(s) not created!
Error in compileCode(f, code, language = language, verbose = verbose) : 
  cc1plus.exe: fatal error: \server/userhome/students4/My Documents/R/win-library/4.0/StanHeaders/include/stan/math/prim/mat/fun/Eigen.hpp: No such file or directorycompilation terminated.make: *** [C:/Users/R/R-40~1.3/etc/x64/Makeconf:229: file29e05485510a.o] Error 1
In addition: Warning message:
In system(paste(CXX, ARGS), ignore.stdout = TRUE, ignore.stderr = TRUE) :
  'C:/Users/R-34~1.3/rtools40/usr/mingw_/bin/g++' not found

```

---

<div class="post-metadata">

**Author:** ![andrjohns](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.mc-stan.org/andrjohns/32/15297_2.png) [@andrjohns](https://discourse.mc-stan.org/u/andrjohns)\
**Post date:** [November 10, 2020, 11:36am UTC](https://discourse.mc-stan.org/t/modeling-failed-warnings-c-users-r-34-1-3-rtools40-usr-mingw-bin-g-not-found-errors-multiple-results-for-cxx14flags-found-something-is-wrong-false/19154/46 "2020-11-10T11:36:14Z")

</div>

Alright, I think this is happening because the `rstan` and `StanHeaders` packages are installed on a networked drive.

First, double-check that the file is definitely there by running:

```
length(list.files("~/R/win-library/4.0/StanHeaders/include/stan/math/prim/mat/fun/"))

```

It should return 215.

If that’s all fine, then you’ll need to remove `rstan` and `StanHeaders` and install them in a local directory on your computer (not on the network drive). Did you need information on how to do that?

---

<div class="post-metadata">

**Author:** ![ASaeed](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.mc-stan.org/asaeed/32/9589_2.png) [@ASaeed](https://discourse.mc-stan.org/u/ASaeed)\
**Post date:** [November 10, 2020, 11:39am UTC](https://discourse.mc-stan.org/t/modeling-failed-warnings-c-users-r-34-1-3-rtools40-usr-mingw-bin-g-not-found-errors-multiple-results-for-cxx14flags-found-something-is-wrong-false/19154/47 "2020-11-10T11:39:15Z")

</div>

> [@andrjohns](#):
>
> ```no-highlight
> length(list.files("~/R/win-library/4.0/StanHeaders/include/stan/math/prim/mat/fun/"))
> 
> ```

That’s strange, because I am saving them in to the local folder I have access to in the C drive. What do you mean by a network driver? Is it the server location? I am sorry I am not tech savvy.  
Here is the output from the line you gave me.

length(list.files(“~/R/win-library/4.0/StanHeaders/include/stan/math/prim/mat/fun/”))  
[1] 215

---

<div class="post-metadata">

**Author:** ![andrjohns](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.mc-stan.org/andrjohns/32/15297_2.png) [@andrjohns](https://discourse.mc-stan.org/u/andrjohns)\
**Post date:** [November 10, 2020, 11:48am UTC](https://discourse.mc-stan.org/t/modeling-failed-warnings-c-users-r-34-1-3-rtools40-usr-mingw-bin-g-not-found-errors-multiple-results-for-cxx14flags-found-something-is-wrong-false/19154/48 "2020-11-10T11:48:35Z")

</div>

It’s because when you install a package via `install.packages` it installs into a folder on `\server/userhome/students4/My Documents/`, which is located a networked drive, not a drive on your computer. This can cause issues for RStan with accessing files

Let’s try this, first restart R. Then remove the `rstan` and `StanHeaders` packages:

```
remove.packages(c("rstan","StanHeaders"))

```

Then, install them to your local library (taken from an earlier post):

```
install.packages("rstan",lib="C:/Users/R/R-4.0.3/library")

```

Does that install without erroring?

---

<div class="post-metadata">

**Author:** ![ASaeed](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.mc-stan.org/asaeed/32/9589_2.png) [@ASaeed](https://discourse.mc-stan.org/u/ASaeed)\
**Post date:** [November 10, 2020, 12:04pm UTC](https://discourse.mc-stan.org/t/modeling-failed-warnings-c-users-r-34-1-3-rtools40-usr-mingw-bin-g-not-found-errors-multiple-results-for-cxx14flags-found-something-is-wrong-false/19154/49 "2020-11-10T12:04:41Z")

</div>

Yes. Install happened without errors. What shall I do now?

---

<div class="post-metadata">

**Author:** ![andrjohns](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.mc-stan.org/andrjohns/32/15297_2.png) [@andrjohns](https://discourse.mc-stan.org/u/andrjohns)\
**Post date:** [November 10, 2020, 12:06pm UTC](https://discourse.mc-stan.org/t/modeling-failed-warnings-c-users-r-34-1-3-rtools40-usr-mingw-bin-g-not-found-errors-multiple-results-for-cxx14flags-found-something-is-wrong-false/19154/50 "2020-11-10T12:06:02Z")

</div>

Can you try the example model from above again?

---

<div class="post-metadata">

**Author:** ![ASaeed](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.mc-stan.org/asaeed/32/9589_2.png) [@ASaeed](https://discourse.mc-stan.org/u/ASaeed)\
**Post date:** [November 10, 2020, 12:08pm UTC](https://discourse.mc-stan.org/t/modeling-failed-warnings-c-users-r-34-1-3-rtools40-usr-mingw-bin-g-not-found-errors-multiple-results-for-cxx14flags-found-something-is-wrong-false/19154/51 "2020-11-10T12:08:40Z")

</div>

Sadly I got the following error.  
Compilation ERROR, function(s)/method(s) not created!  
Error in compileCode(f, code, language = language, verbose = verbose) :  
cc1plus.exe: fatal error: \server/userhome/students4/My Documents/R/win-library/4.0/StanHeaders/include/stan/math/prim/mat/fun/Eigen.hpp: No such file or directorycompilation terminated.make: \*\*\* [C:/Users/R/R-40~1.3/etc/x64/Makeconf:229: file5ea43a8f64e0.o] Error 1  
In addition: Warning message:  
In system(paste(CXX, ARGS), ignore.stdout = TRUE, ignore.stderr = TRUE) :  
‘C:/Users/R-34~1.3/rtools40/usr/mingw\_/bin/g++’ not found

---

<div class="post-metadata">

**Author:** ![ASaeed](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.mc-stan.org/asaeed/32/9589_2.png) [@ASaeed](https://discourse.mc-stan.org/u/ASaeed)\
**Post date:** [November 10, 2020, 12:23pm UTC](https://discourse.mc-stan.org/t/modeling-failed-warnings-c-users-r-34-1-3-rtools40-usr-mingw-bin-g-not-found-errors-multiple-results-for-cxx14flags-found-something-is-wrong-false/19154/52 "2020-11-10T12:23:54Z")

</div>

Do you think there is a reason why it can’t locate “C:/Users/R-34~1.3/rtools40/usr/mingw\_/bin/g++’ not found” ??  
Unfortunately its getting late here for me. So I might retire since its late here. I shall be able to reply again tomorrow morning.

---

<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:** [November 10, 2020, 3:45pm UTC](https://discourse.mc-stan.org/t/modeling-failed-warnings-c-users-r-34-1-3-rtools40-usr-mingw-bin-g-not-found-errors-multiple-results-for-cxx14flags-found-something-is-wrong-false/19154/53 "2020-11-10T15:45:57Z")

</div>

> [@ASaeed](#):
>
> Do you think there is a reason why it can’t locate “C:/Users/R-34~1.3/rtools40/usr/mingw\_/bin/g++’ not found” ??

Yes, but don’t worry about it.

---

<div class="post-metadata">

**Author:** ![andrjohns](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.mc-stan.org/andrjohns/32/15297_2.png) [@andrjohns](https://discourse.mc-stan.org/u/andrjohns)\
**Post date:** [November 11, 2020, 2:22am UTC](https://discourse.mc-stan.org/t/modeling-failed-warnings-c-users-r-34-1-3-rtools40-usr-mingw-bin-g-not-found-errors-multiple-results-for-cxx14flags-found-something-is-wrong-false/19154/54 "2020-11-11T02:22:35Z")

</div>

Alright, let’s try moving the entire package installation directory to your local drive (i.e., all R packages will get installed to a folder on your computer, rather than the network drive).

First we need to remove those RStan and StanHeaders packages:

```
remove.packages(c("rstan","StanHeaders"))

```

And restart R.

Given that we know you have permissions to the `C:/Users/R` folder, we’ll create a folder there which your packages will be installed into:

```
dir.create("C:/Users/R/win-library/4.0", recursive = T)

```

Next, we need to tell R to install and load R packages from this directory. We can do this by setting the `R_LIBS_USER` environment variable using your `.Renviron` file:

```
cat("R_LIBS_USER = \"C:/Users/R/win-library/4.0\"",
    file="~/.Renviron", append=TRUE)

```

And then restart R. If you look at the ‘Packages’ pane in RStudio, you should only see packages listed under ‘System Library’. Next, we’ll copy R packages from your old directory to this new one (otherwise you’ll have to re-install them all):

```
file.copy(from="~/R/win-library/4.0/",to="C:/Users/R/win-library/",recursive = T)

```

Depending on how many packages you have installed, this could take a few minutes. Then restart R again.

If all of the above ran without any errors (fingers crossed), then try to install RStan and run the example model again:

```
install.packages("rstan")
library(rstan)
example(stan_model, run.dontrun=T)

```

---

<div class="post-metadata">

**Author:** ![ASaeed](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.mc-stan.org/asaeed/32/9589_2.png) [@ASaeed](https://discourse.mc-stan.org/u/ASaeed)\
**Post date:** [November 11, 2020, 4:16am UTC](https://discourse.mc-stan.org/t/modeling-failed-warnings-c-users-r-34-1-3-rtools40-usr-mingw-bin-g-not-found-errors-multiple-results-for-cxx14flags-found-something-is-wrong-false/19154/55 "2020-11-11T04:16:41Z")

</div>

Thanks Andrjohns. I did all the steps, and after I ran the model  
I got this

Warning message:  
In system(paste(CXX, ARGS), ignore.stdout = TRUE, ignore.stderr = TRUE) :  
‘C:/Users/R-34~1.3/rtools40/usr/mingw\_/bin/g++’ not found

---

<div class="post-metadata">

**Author:** ![andrjohns](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.mc-stan.org/andrjohns/32/15297_2.png) [@andrjohns](https://discourse.mc-stan.org/u/andrjohns)\
**Post date:** [November 11, 2020, 4:20am UTC](https://discourse.mc-stan.org/t/modeling-failed-warnings-c-users-r-34-1-3-rtools40-usr-mingw-bin-g-not-found-errors-multiple-results-for-cxx14flags-found-something-is-wrong-false/19154/56 "2020-11-11T04:20:53Z")

</div>

That warning is completely safe to ignore, it will be fixed in the next release. Did everything run and finish sampling?

---

<div class="post-metadata">

**Author:** ![ASaeed](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.mc-stan.org/asaeed/32/9589_2.png) [@ASaeed](https://discourse.mc-stan.org/u/ASaeed)\
**Post date:** [November 11, 2020, 6:12am UTC](https://discourse.mc-stan.org/t/modeling-failed-warnings-c-users-r-34-1-3-rtools40-usr-mingw-bin-g-not-found-errors-multiple-results-for-cxx14flags-found-something-is-wrong-false/19154/57 "2020-11-11T06:12:14Z")

</div>

Yes! I am super thankful!!! You have been such a great help on this, I sincerely appreciate it!!!

---

<div class="post-metadata">

**Author:** ![andrjohns](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.mc-stan.org/andrjohns/32/15297_2.png) [@andrjohns](https://discourse.mc-stan.org/u/andrjohns)\
**Post date:** [November 11, 2020, 6:20am UTC](https://discourse.mc-stan.org/t/modeling-failed-warnings-c-users-r-34-1-3-rtools40-usr-mingw-bin-g-not-found-errors-multiple-results-for-cxx14flags-found-something-is-wrong-false/19154/58 "2020-11-11T06:20:12Z")

</div>

Fantastic news! Thanks for hanging in there with the debugging, and sorry that it’s been such a journey.

---

<div class="post-metadata">

**Author:** ![ASaeed](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.mc-stan.org/asaeed/32/9589_2.png) [@ASaeed](https://discourse.mc-stan.org/u/ASaeed)\
**Post date:** [November 11, 2020, 6:37am UTC](https://discourse.mc-stan.org/t/modeling-failed-warnings-c-users-r-34-1-3-rtools40-usr-mingw-bin-g-not-found-errors-multiple-results-for-cxx14flags-found-something-is-wrong-false/19154/59 "2020-11-11T06:37:39Z")

</div>

Not at all, actually this has been the quickest debugging I have ever had! So I am super thankful, and you gave me insights on the problem which I had no idea about.

---

<div class="post-metadata">

**Author:** ![jonah](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.mc-stan.org/jonah/32/200_2.png) [@jonah](https://discourse.mc-stan.org/u/jonah)\
**Post date:** [November 11, 2020, 8:35pm UTC](https://discourse.mc-stan.org/t/modeling-failed-warnings-c-users-r-34-1-3-rtools40-usr-mingw-bin-g-not-found-errors-multiple-results-for-cxx14flags-found-something-is-wrong-false/19154/60 "2020-11-11T20:35:06Z")

</div>

Glad it’s working now @ASaeed!

> [@andrjohns](#):
>
> Fantastic news! Thanks for hanging in there with the debugging, and sorry that it’s been such a journey.

And seriously thanks to you @andrjohns for hanging in there and helping them get everything sorted out. That was quite the debugging journey!

[Previous page](https://discourse.mc-stan.org/t/modeling-failed-warnings-c-users-r-34-1-3-rtools40-usr-mingw-bin-g-not-found-errors-multiple-results-for-cxx14flags-found-something-is-wrong-false/19154.md?page=2)

[Next page](https://discourse.mc-stan.org/t/modeling-failed-warnings-c-users-r-34-1-3-rtools40-usr-mingw-bin-g-not-found-errors-multiple-results-for-cxx14flags-found-something-is-wrong-false/19154.md?page=4)
