Brms and rstan compilation error


I was trying to run a very simple model in brms. However, it keeps throwing errors.

brm(data = Concern_data,
                        Response ~ 1 ,
                        iter = 4000, warmup = 1000, chains = 4, cores = 4)

Here is the error:

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

It doesn’t appear to be a brms issue specifically, as running this code also provides the same error:

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

I’ve tried a few different solutions but nothing seems to be working for me.

It looks like it could be some R tools related problem, but following these instructions also didn’t solve the issue (Using Rtools4 on Windows). Though, it seems these apply for R tools version 4.0 only? (I installed version 4.2).

I’m unsure what else I can try. Any help would be greatly appreciated.

OS = Windows 10
brms version = 2.18.0
R version = 4.2.1 (working in latest version of R studio)

See the Rstan Getting Started Guide

Perfect, that’s solved the problem.

Many thanks!