# CompileCode error

**URL:** <https://discourse.mc-stan.org/t/compilecode-error/32419>\
**Category:** RStan\
**Created:** [August 10, 2023, 5:58pm UTC](https://discourse.mc-stan.org/t/compilecode-error/32419 "2023-08-10T17:58:12Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Alicia\_Carriquiry](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.mc-stan.org/alicia_carriquiry/32/16631_2.png) [@Alicia\_Carriquiry](https://discourse.mc-stan.org/u/Alicia_Carriquiry)\
**Post date:** [August 10, 2023, 5:58pm UTC](https://discourse.mc-stan.org/t/compilecode-error/32419/1 "2023-08-10T17:58:12Z")

</div>

I just got a new laptop that has R 4.3.1 loaded. I installed rstan from within RStudio. I am running a relatively simple model, but get the following error:

Error in compileCode(f, code, language = language, verbose = verbose) :  
C:\rtools43\x86\_64-w64-mingw32.static.posix\bin/ld.exe: file611443683aae.o:file611443683aae.cpp:(.text$\_ZN3tbb8internal26task\_scheduler\_observer\_v3D0Ev[\_ZN3tbb8internal26task\_scheduler\_observer\_v3D0Ev]+0x1c): undefined reference to `tbb::internal::task_scheduler_observer_v3::observe(bool)'C:\rtools43\x86_64-w64-mingw32.static.posix\bin/ld.exe: file611443683aae.o:file611443683aae.cpp:(.text$_ZN3tbb10interface623task_scheduler_observerD1Ev[_ZN3tbb10interface623task_scheduler_observerD1Ev]+0x1c): undefined reference to `tbb::internal::task\_scheduler\_observer\_v3::observe(bool)'C:\rtools43\x86\_64-w64-mingw32.static.posix\bin/ld.exe: file611443683aae.o:file611443683aae.cpp:(.text$\_ZN3tbb10interface623task\_scheduler\_observerD1Ev[\_ZN3tbb10interface623task\_scheduler\_observerD1Ev]+0x37): undefined reference to `tbb::internal::task\_scheduler\_observer\_v3::observe(bool)'C:\rtools43\x86\_64-w64-mingw32.static.posix\bin/ld.exe: file611443683aae.o:file611443683aae.cpp:(.text$\_ZN3tbb10interface  
In addition: Warning message:  
In readLines(file, warn = TRUE) :  
incomplete final line found on ‘C:\Users\alicia\Dropbox\Consulting\CristinaPardo\ThreeParameterStan-Aug2023\reading-model.stan’  
Error in sink(type = “output”) : invalid connection

Any suggestions? I am at a loss. Thanks in advance!

---

<div class="post-metadata">

**Author:** ![UCLPG-MSC-SGDS](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.mc-stan.org/uclpg-msc-sgds/32/15697_2.png) [@UCLPG-MSC-SGDS](https://discourse.mc-stan.org/u/UCLPG-MSC-SGDS)\
**Post date:** [August 11, 2023, 2:07pm UTC](https://discourse.mc-stan.org/t/compilecode-error/32419/2 "2023-08-11T14:07:05Z")

</div>

Hello, you could try the solution that was posted to another problem that’s akin to yours. See post below:

> [@Error in compilation after rstan reinstall](https://discourse.mc-stan.org/t/error-in-compilation-after-rstan-reinstall/32087):
>
> Hi, I recently had to uninstall and reinstall R, and thus all packages (including “StanHeaders” and “rstan”). I am trying to run a model with a code that previously worked without any trouble, but I am getting this error when I try to compile the Stan model: \> StanModel \<- stan\_model(here("Stan\_models/model\_vaccination.stan")) make cmd is make -f "C:/PROGRA~1/R/R-43~1.0/etc/x64/Makeconf" -f "C:/PROGRA~1/R/R-43~1.0/share/make/winshlib.mk" -f "C:/Users/nd1316/Documents/.R/Makevars.win" CXX='$(…

The solution will require you to use R. 4.2.3 and Rtools 4.2. for now, I hope this resolves your problem.

---

<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:** [August 14, 2023, 9:17am UTC](https://discourse.mc-stan.org/t/compilecode-error/32419/3 "2023-08-14T09:17:37Z")

</div>

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