1

I have just installed R, then RStudio and RTools. I tried to install brms, though I succeeded but when I try to use it I get an error message (see below). What shouuld I do?

Compiling Stan program...
make cmd is
  make -f "C:/PROGRA~1/R/R-42~1.3/etc/x64/Makeconf" -f "C:/PROGRA~1/R/R-42~1.3/share/make/winshlib.mk" CXX='$(CXX14) $(CXX14STD)' CXXFLAGS='$(CXX14FLAGS)' CXXPICFLAGS='$(CXX14PICFLAGS)' SHLIB_LDFLAGS='$(SHLIB_CXX14LDFLAGS)' SHLIB_LD='$(SHLIB_CXX14LD)' SHLIB="filecd811e778aa.dll" WIN=64 TCLBIN= OBJECTS="filecd811e778aa.o"

make would use
if test "zfilecd811e778aa.o" != "z"; then \
  if test -e "filecd811e778aa-win.def"; then \
    echo g++  -shared -s -static-libgcc -o filecd811e778aa.dll filecd811e778aa-win.def filecd811e778aa.o  -L"C:/rtools42/x86_64-w64-mingw32.static.posix/lib/x64" -L"C:/rtools42/x86_64-w64-mingw32.static.posix/lib"  -L"C:/PROGRA~1/R/R-42~1.3/bin/x64" -lR ; \
    g++  -shared -s -static-libgcc -o filecd811e778aa.dll filecd811e778aa-win.def filecd811e778aa.o  -L"C:/rtools42/x86_64-w64-mingw32.static.posix/lib/x64" -L"C:/rtools42/x86_64-w64-mingw32.static.posix/lib"  -L"C:/PROGRA~1/R/R-42~1.3/bin/x64" -lR ; \
  else \
    echo EXPORTS > tmp.def; \
    nm filecd811e778aa.o | sed -n 's/^.* [BCDRT] / /p' | sed -e '/[.]refptr[.]/d' -e '/[.]weak[.]/d' | sed 's/[^ ][^ ]*/"&"/g'  >> tmp.def; \
    echo g++  -shared -s -static-libgcc -o filecd811e778aa.dll tmp.def filecd811e778aa.o  -L"C:/rtools42/x86_64-w64-mingw32.static.posix/lib/x64" -L"C:/rtools42/x86_64-w64-mingw32.static.posix/lib"  -L"C:/PROGRA~1/R/R-42~1.3/bin/x64" -lR ; \
    g++  -shared -s -static-libgcc -o filecd811e778aa.dll tmp.def filecd811e778aa.o  -L"C:/rtools42/x86_64-w64-mingw32.static.posix/lib/x64" -L"C:/rtools42/x86_64-w64-mingw32.static.posix/lib"  -L"C:/PROGRA~1/R/R-42~1.3/bin/x64" -lR ; \
    rm -f tmp.def; \
  fi \
fi
Error in compileCode(f, code, language = language, verbose = verbose) : 
  C:\rtools42\x86_64-w64-mingw32.static.posix\bin/ld.exe: filecd811e778aa.o:filecd811e778aa.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: filecd811e778aa.o:filecd811e778aa.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: filecd811e778aa.o:filecd811e778aa.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: filecd811e778aa.o:filecd811e778aa.cpp:(.text$_ZN3tbb10interface623task_
Error in sink(type = "output") : invalid connection
> library(rstan)
user438383
  • 5,716
  • 8
  • 28
  • 43
RNewbie
  • 15
  • 6
  • You ought to show your R version, the version of the relevant packages (i.e. brms, rstan). – Carlos Luis Rivera Jul 06 '23 at 13:58
  • If you want to install the latest `rstan`, run `install.packages("rstan", repos = c("https://mc-stan.org/r-packages/", getOption("repos")))`, as described in [here](https://mc-stan.org/r-packages/#:~:text=install.packages(%22rstan%22%2C%20repos%20%3D%20c(%22https%3A//mc%2Dstan.org/r%2Dpackages/%22%2C%20getOption(%22repos%22)))). Moreover, you should install Rtools that is compatible to your R version; see [here](https://cran.r-project.org/bin/windows/Rtools/) – Carlos Luis Rivera Jul 06 '23 at 14:10
  • R 4.2.3 brms 2.19 rstan 2.21.8 – RNewbie Jul 06 '23 at 14:17
  • @CarlosLuisRivera I did install the RTools compatible with my R version – RNewbie Jul 06 '23 at 14:18
  • [this](https://discourse.mc-stan.org/t/error-in-sink-type-output-invalid-connection/20672/2) suggests `install.packages(c("StanHeaders","rstan"),type="source")` – Ben Bolker Jul 06 '23 at 14:45

0 Answers0