Issues while installing Rstan after R update to 4.2.1

Dear all,

I Write you today because for the first time I have some troubles regarding the Rstan installation. I recently updated R to version 4.2.1 and Rtools to 4.2.0 in order to try Nimble. Then I was unable to use RStan.

I deleted all R and Rstudio stuff on my computer (Windows 10), uninstall R, Rstudio, Rtools several times. However I still have this issue that is detailed on the: RStan Getting Started · stan-dev/rstan Wiki · GitHub


Error in compileCode(f, code, language = language, verbose = verbose) :
C:\rtools42\x86_64-w64-mingw32.static.posix\bin/ld.exe: filed3479062fcc.o:filed3479062fcc.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: filed3479062fcc.o:filed3479062fcc.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: filed3479062fcc.o:filed3479062fcc.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: filed3479062fcc.o:filed3479062fcc.cpp:(.text$ZN3tbb10interface623task

I tried to install Rstan and StanHeaders from source as it is recommended on the page. But it does not work.

Maybe a problem with Makevars ?

As I don’t know what information is useful for you at the moment, I won’t add anything superfluous. But don’t hesitate to ask me for any information!

I specify that my level of computer science is rather low. I may not understand your instructions too well afterwards.

Kind regards,


see Stan & R 4.2 on Windows – The Stan Blog

Dear Rok,

Thank you for your quick response. Actually everything works with :

R version: 4.1.3
Rtools version : 4.0


Do you mean that you downgraded back to 4.1 and that fixed your case? Great if that is the case, I will mark this thread as solved then.

I just wanted to point out that if using R 4.2, you should use the instructions in the linked blog as the CRAN version of rstan does not currently work with R4.2 on Windows.