Hi all, I’m working on an R package that uses rstan for estimation. When I ran the devtools::check_rhub() to check the package, I encountered the error specific to rstan on Windows that can be fixed by making changes to the local computers (https://discourse.mc-stan.org/t/rstan-on-windows/16673…)
make -f "C:/PROGRA~1/R/R-devel/etc/x64/Makeconf" -f "C:/PROGRA~1/R/R-devel/share/make/winshlib.mk" -f "C:\Users\USERozsLrYfilk/.R/Makevars.win64" CXX='$(CXX14) $(CXX14STD)' CXXFLAGS='$(CXX14FLAGS)' CXXPICFLAGS='$(CXX14PICFLAGS)' SHLIB_LDFLAGS='$(SHLIB_CXX14LDFLAGS)' SHLIB_LD='$(SHLIB_CXX14LD)' SHLIB="file1804377c331b.dll" WIN=64 TCLBIN=64 OBJECTS="file1804377c331b.o"
807#> make would use
808#> if test "zfile1804377c331b.o" != "z"; then \
809#> if test -e "file1804377c331b-win.def"; then \
810#> echo "C:/rtools40/mingw64/bin/"g++ -shared -s -static-libgcc -o file1804377c331b.dll file1804377c331b-win.def file1804377c331b.o -L"c:/R/local330/lib/x64" -L"c:/R/local330/lib" -L"C:/PROGRA~1/R/R-devel/bin/x64" -lR ; \
811#> "C:/rtools40/mingw64/bin/"g++ -shared -s -static-libgcc -o file1804377c331b.dll file1804377c331b-win.def file1804377c331b.o -L"c:/R/local330/lib/x64" -L"c:/R/local330/lib" -L"C:/PROGRA~1/R/R-devel/bin/x64" -lR ; \
812#> else \
813#> echo EXPORTS > tmp.def; \
814#> "C:/rtools40/mingw64/bin/"nm file1804377c331b.o | sed -n 's/^.* [BCDRT] / /p' | sed -e '/[.]refptr[.]/d' -e '/[.]weak[.]/d' | sed 's/[^ ][^ ]*/"&"/g' >> tmp.def; \
815#> echo "C:/rtools40/mingw64/bin/"g++ -shared -s -static-libgcc -o file1804377c331b.dll tmp.def file1804377c331b.o -L"c:/R/local330/lib/x64" -L"c:/R/local330/lib" -L"C:/PROGRA~1/R/R-devel/bin/x64" -lR ; \
816#> "C:/rtools40/mingw64/bin/"g++ -shared -s -static-libgcc -o file1804377c331b.dll tmp.def file1804377c331b.o -L"c:/R/local330/lib/x64" -L"c:/R/local330/lib" -L"C:/PROGRA~1/R/R-devel/bin/x64" -lR ; \
817#> rm -f tmp.def; \
818#> fi \
819#> fi
820#> C:/rtools40/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/8.3.0/../../../../x86_64-w64-mingw32/bin/ld.exe: file1804377c331b.o:file1804377c331b.cpp:(.text$_ZN3tbb8internal26task_scheduler_observer_v3D1Ev[_ZN3tbb8internal26task_scheduler_observer_v3D1Ev]+0x14): undefined reference to `tbb::internal::task_scheduler_observer_v3::observe(bool)'C:/rtools40/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/8.3.0/../../../../x86_64-w64-mingw32/bin/ld.exe: file1804377c331b.o:file1804377c331b.cpp:(.text$_ZN3tbb8internal26task_scheduler_observer_v3D0Ev[_ZN3tbb8internal26task_scheduler_observer_v3D0Ev]+0x1c): undefined reference to `tbb::internal::task_scheduler_observer_v3::observe(bool)'C:/rtools40/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/8.3.0/../../../../x86_64-w64-mingw32/bin/ld.exe: file1804377c331b.o:file1804377c331b.cpp:(.text$_ZN4stan4math16ad_tape_observerD1Ev[_ZN4stan4math16ad_tape_observerD1Ev]+0x15): undefined reference to `tbb::internal::task_scheduler_observer_v3::observe(bool)'C:/rto
821#> Calls: ... -> -> force -> cxxfunction -> compileCode
822#> Error in sink(type = "output") : invalid connection
823#> Calls: ... -> stan_model -> cxxfunctionplus -> sink
824#> Execution halted
825#> Error in compileCode(f, code, language = language, verbose = verbose) :
but when I ran the check_win_devel, there was no error. And also when I used “dontrun” for my examples in the documentation, there was no error, but CRAN requires the change from “dontrun” to “donttest”, and now I’m using “donttest”, the error occurs. Any suggestions about how to fix the error in the r package to make it work on Windows? Thanks!