# Why does running the tutorial example fail with Rstan?

**URL:** <https://discourse.mc-stan.org/t/why-does-running-the-tutorial-example-fail-with-rstan/30316>\
**Category:** Interfaces\
**Tags:** rstan\
**Created:** [February 9, 2023, 10:45am UTC](https://discourse.mc-stan.org/t/why-does-running-the-tutorial-example-fail-with-rstan/30316 "2023-02-09T10:45:37Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![AlexanderDeGraaf](https://avatars.discourse-cdn.com/v4/letter/a/278dde/32.png) [@AlexanderDeGraaf](https://discourse.mc-stan.org/u/AlexanderDeGraaf)\
**Post date:** [February 9, 2023, 10:45am UTC](https://discourse.mc-stan.org/t/why-does-running-the-tutorial-example-fail-with-rstan/30316/1 "2023-02-09T10:45:37Z")

</div>

I installed the RStan successfully, the library loads. I try to run a tutorial example ([RStan Getting Started · stan-dev/rstan Wiki · GitHub](https://github.com/stan-dev/rstan/wiki/RStan-Getting-Started#example-1-eight-schools)). After applying the `stan` function

```plaintext
fit1 <- stan(
  file = "schools.stan", # Stan program
  data = schools_data, # named list of data
  chains = 4, # number of Markov chains
  warmup = 1000, # number of warmup iterations per chain
  iter = 2000, # total number of iterations per chain
  cores = 1, # number of cores (could use one per chain)
  refresh = 0 # no progress shown
)

```

I get the following error:

_Error in compileCode(f, code, language = language, verbose = verbose) :  
C:\rtools42\x86\_64-w64-mingw32.static.posix\bin/ld.exe: file1c34165764a4.o:file1c34165764a4.cpp:(.text$\_ZN3tbb8internal26task\_scheduler\_observer\_v3D0Ev[\_ZN3tbb8internal26task\_scheduler\_observer\_v3D0Ev]+0x1d): undefined reference to `tbb::internal::task_scheduler_observer_v3::observe(bool)'C:\rtools42\x86_64-w64-mingw32.static.posix\bin/ld.exe: file1c34165764a4.o:file1c34165764a4.cpp:(.text$_ZN3tbb10interface623task_scheduler_observerD1Ev[_ZN3tbb10interface623task_scheduler_observerD1Ev]+0x1d): undefined reference to `tbb::internal::task\_scheduler\_observer\_v3::observe(bool)'C:\rtools42\x86\_64-w64-mingw32.static.posix\bin/ld.exe: file1c34165764a4.o:file1c34165764a4.cpp:(.text$\_ZN3tbb10interface623task\_scheduler\_observerD1Ev[\_ZN3tbb10interface623task\_scheduler\_observerD1Ev]+0x3a): undefined reference to `tbb::internal::task\_scheduler\_observer\_v3::observe(bool)'C:\rtools42\x86\_64-w64-mingw32.static.posix\bin/ld.exe: file1c34165764a4.o:file1c34165764a4.cpp:(.text$\_ZN3tbb10interface  
Error in sink(type = “output”) : invalid connection_

Simply running `example(stan_model, run.dontrun=T)` gives the same error.

What does this error mean?

Is rtools wrongly installed? My PATH seems to contain the correct folder `C:\\rtools42\\x86_64-w64-mingw32.static.posix\\bin;`. Is something wrong with the version of my Rstan package? I am struggling to interpret this error?

What to try to solve 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:** [February 9, 2023, 12:30pm UTC](https://discourse.mc-stan.org/t/why-does-running-the-tutorial-example-fail-with-rstan/30316/2 "2023-02-09T12:30:50Z")

</div>

See the [Getting Started Guide](https://github.com/stan-dev/rstan/wiki/Configuring-C---Toolchain-for-Windows#r-42)
