# Installation error

**URL:** <https://discourse.mc-stan.org/t/installation-error/24745>\
**Category:** General\
**Tags:** installation\
**Created:** [October 6, 2021, 11:10pm UTC](https://discourse.mc-stan.org/t/installation-error/24745 "2021-10-06T23:10:26Z")\
**Posts on this page:** 13\
**Page:** 1

<div class="post-metadata">

**Author:** ![ts1](https://avatars.discourse-cdn.com/v4/letter/t/a8b319/32.png) [@ts1](https://discourse.mc-stan.org/u/ts1)\
**Post date:** [October 6, 2021, 11:10pm UTC](https://discourse.mc-stan.org/t/installation-error/24745/1 "2021-10-06T23:10:26Z")

</div>

Hi,

I followed these steps to install rstan: [RStan Getting Started · stan-dev/rstan Wiki · GitHub](https://github.com/stan-dev/rstan/wiki/RStan-Getting-Started)

Including these steps: [Configuring C Toolchain for Windows · stan-dev/rstan Wiki · GitHub](https://github.com/stan-dev/rstan/wiki/Configuring-C---Toolchain-for-Windows)

Everything looked ok with no errors until I ran  
install.packages(“rstan”, repos = “[https://cloud.r-project.org/](https://cloud.r-project.org/)”, dependencies = TRUE)

and received this error:

```
* installing *source* package 'rstan' ...
** package 'rstan' successfully unpacked and MD5 sums checked
** libs

*** arch - i386
Error in .shlib_internal(args) : 
  C++14 standard requested but CXX14 is not defined

```

Can you advise what the issue is?

My makevars.win file looks like

CXX14FLAGS += -mtune=native -O3 -mmmx -msse -msse2 -msse3 -mssse3 -msse4.1 -msse4.2

I have r version 3.5.2 and Rtools version 3.5.0.4. I can install a package from source.

I also tried installing from cran and received the same errror.

Thank you

---

<div class="post-metadata">

**Author:** ![ts1](https://avatars.discourse-cdn.com/v4/letter/t/a8b319/32.png) [@ts1](https://discourse.mc-stan.org/u/ts1)\
**Post date:** [October 8, 2021, 1:39am UTC](https://discourse.mc-stan.org/t/installation-error/24745/2 "2021-10-08T01:39:47Z")

</div>

Any suggestions on this issue?

---

<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:** [October 8, 2021, 2:49am UTC](https://discourse.mc-stan.org/t/installation-error/24745/3 "2021-10-08T02:49:31Z")

</div>

Can you try running:

```r
cat("CXX14 = $(BINPREF)g++ -std=c++1y",
    file = "~/.R/Makevars.win", sep = "\n", append = TRUE)

```

Then restart R and try the install again?

---

<div class="post-metadata">

**Author:** ![ts1](https://avatars.discourse-cdn.com/v4/letter/t/a8b319/32.png) [@ts1](https://discourse.mc-stan.org/u/ts1)\
**Post date:** [October 8, 2021, 3:49pm UTC](https://discourse.mc-stan.org/t/installation-error/24745/4 "2021-10-08T15:49:01Z")

</div>

After running that I received this warning message:

```
Warning message:
In normalizePath(path.expand(path), winslash, mustWork) :
  path[1]="NA": The system cannot find the file specified

```

But it did successfully install 2.21.2

Thank you!

---

<div class="post-metadata">

**Author:** ![jonathan.t.levy90](https://avatars.discourse-cdn.com/v4/letter/j/3d9bf3/32.png) [@jonathan.t.levy90](https://discourse.mc-stan.org/u/jonathan.t.levy90)\
**Post date:** [June 19, 2022, 5:34am UTC](https://discourse.mc-stan.org/t/installation-error/24745/5 "2022-06-19T05:34:31Z")

</div>

I have a question (not sure if this is the right place to post but the topic seems related). After installing RStan I tried to verify my installation by running:

example(stan\_model, package = “rstan”, run.dontrun = TRUE)

After doing so I then got this error message:

Compilation ERROR, function(s)/method(s) not created!  
Error in compileCode(f, code, language = language, verbose = verbose) :  
C:/RBuildTools/4.0/mingw64/bin/…/lib/gcc/x86\_64-w64-mingw32/8.3.0/…/…/…/…/x86\_64-w64-mingw32/bin/ld.exe: file6834192127b1.o:file6834192127b1.cpp:(.text$\_ZN3tbb8internal26task\_scheduler\_observer\_v3D1Ev[\_ZN3tbb8internal26task\_scheduler\_observer\_v3D1Ev]+0x14): undefined reference to `tbb::internal::task_scheduler_observer_v3::observe(bool)'C:/RBuildTools/4.0/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/8.3.0/../../../../x86_64-w64-mingw32/bin/ld.exe: file6834192127b1.o:file6834192127b1.cpp:(.text$_ZN3tbb8internal26task_scheduler_observer_v3D0Ev[_ZN3tbb8internal26task_scheduler_observer_v3D0Ev]+0x1c): undefined reference to `tbb::internal::task\_scheduler\_observer\_v3::observe(bool)'C:/RBuildTools/4.0/mingw64/bin/…/lib/gcc/x86\_64-w64-mingw32/8.3.0/…/…/…/…/x86\_64-w64-mingw32/bin/ld.exe: file6834192127b1.o:file6834192127b1.cpp:(.text$\_ZN3tbb10interface623task\_scheduler\_observerD0Ev[\_ZN3tbb10interface623task\_scheduler\_observerD0Ev]+0x1c): undefined reference to `tbb::internal::t

So I restarted R and reinstalled RStan and Stan headers by entering:

Sys.setenv(MAKEFLAGS = paste0("-j",parallel::detectCores()))

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

However, I still get the same error message when I try to verify my RStan installation. What should I do?

I basically followed the steps outlined in: [RStan Getting Started · stan-dev/rstan Wiki · GitHub](https://github.com/stan-dev/rstan/wiki/RStan-Getting-Started)

---

<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:** [June 19, 2022, 12:13pm UTC](https://discourse.mc-stan.org/t/installation-error/24745/6 "2022-06-19T12:13:43Z")

</div>

What version of R are you using?

---

<div class="post-metadata">

**Author:** ![jonathan.t.levy90](https://avatars.discourse-cdn.com/v4/letter/j/3d9bf3/32.png) [@jonathan.t.levy90](https://discourse.mc-stan.org/u/jonathan.t.levy90)\
**Post date:** [June 19, 2022, 9:38pm UTC](https://discourse.mc-stan.org/t/installation-error/24745/7 "2022-06-19T21:38:30Z")

</div>

I’m using R version 4.2.0 (2022-04-22 ucrt) – “Vigorous Calisthenics”

---

<div class="post-metadata">

**Author:** ![prestonbiro](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.mc-stan.org/prestonbiro/32/14507_2.png) [@prestonbiro](https://discourse.mc-stan.org/u/prestonbiro)\
**Post date:** [June 22, 2022, 12:55pm UTC](https://discourse.mc-stan.org/t/installation-error/24745/8 "2022-06-22T12:55:51Z")

</div>

I’m having the same error as above, also using R version 4.2.0. Any resolution here?

---

<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:** [June 22, 2022, 1:05pm UTC](https://discourse.mc-stan.org/t/installation-error/24745/9 "2022-06-22T13:05:38Z")

</div>

Can you try using the preview of the next rstan version:

```r
remove.packages(c("StanHeaders", "rstan"))
install.packages("StanHeaders", repos = c("https://mc-stan.org/r-packages/", getOption("repos")))
install.packages("rstan", repos = c("https://mc-stan.org/r-packages/", getOption("repos")))

```

---

<div class="post-metadata">

**Author:** ![prestonbiro](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.mc-stan.org/prestonbiro/32/14507_2.png) [@prestonbiro](https://discourse.mc-stan.org/u/prestonbiro)\
**Post date:** [June 22, 2022, 1:23pm UTC](https://discourse.mc-stan.org/t/installation-error/24745/10 "2022-06-22T13:23:46Z")

</div>

That worked! Thanks for your help. For reference for others, my Makevars.win file looks like this:

```nohighlight
CXX14FLAGS += -mtune=native -O3 -mmmx -msse -msse2 -msse3 -mssse3 -msse4.1 -msse4.2

CXX14 = $(BINPREF)g++ -std=c++1y

```

Also, using the following line can help you access your Makevars.win file:

```nohighlight
usethis::edit_r_makevars()

```

---

<div class="post-metadata">

**Author:** ![jonathan.t.levy90](https://avatars.discourse-cdn.com/v4/letter/j/3d9bf3/32.png) [@jonathan.t.levy90](https://discourse.mc-stan.org/u/jonathan.t.levy90)\
**Post date:** [June 24, 2022, 2:45am UTC](https://discourse.mc-stan.org/t/installation-error/24745/11 "2022-06-24T02:45:00Z")

</div>

I entered the code you sent through, then:

example(stan\_model, package = “rstan”, run.dontrun = TRUE)

Now I get this error:

Error: unexpected input in “example(stan\_model, package = “”

Any ideas?

---

<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:** [June 24, 2022, 6:53am UTC](https://discourse.mc-stan.org/t/installation-error/24745/12 "2022-06-24T06:53:54Z")

</div>

The quotation marks get changed by discourse when they’re posted as text to the forum, you need to either change them or you can copy the code block below:

```nohighlight
example(stan_model, package = "rstan", run.dontrun = TRUE)

```

---

<div class="post-metadata">

**Author:** ![jonathan.t.levy90](https://avatars.discourse-cdn.com/v4/letter/j/3d9bf3/32.png) [@jonathan.t.levy90](https://discourse.mc-stan.org/u/jonathan.t.levy90)\
**Post date:** [June 24, 2022, 7:10am UTC](https://discourse.mc-stan.org/t/installation-error/24745/13 "2022-06-24T07:10:16Z")

</div>

My bad. Thank you, it is working now.
