# Error in compileCode(f, code, language = language, verbose = verbose)

**URL:** <https://discourse.mc-stan.org/t/error-in-compilecode-f-code-language-language-verbose-verbose/29064>\
**Category:** RStan\
**Tags:** rstan, brms\
**Created:** [October 7, 2022, 4:10pm UTC](https://discourse.mc-stan.org/t/error-in-compilecode-f-code-language-language-verbose-verbose/29064 "2022-10-07T16:10:31Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ayin\_Ven](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.mc-stan.org/ayin_ven/32/15135_2.png) [@Ayin\_Ven](https://discourse.mc-stan.org/u/Ayin_Ven)\
**Post date:** [October 7, 2022, 4:10pm UTC](https://discourse.mc-stan.org/t/error-in-compilecode-f-code-language-language-verbose-verbose/29064/1 "2022-10-07T16:10:31Z")

</div>

When I run the brms package for analysis, it Compiling Stan program… After the error, I hope I can get your help, thanks.

And here is my sessionINFO()：  
R version 4.2.1 (2022-06-23 ucrt)  
Platform: x86\_64-w64-mingw32/x64 (64-bit)  
Running under: Windows 10 x64 (build 22000)

Matrix products: default

locale:  
[1] LC\_COLLATE=Chinese (Simplified)\_China.utf8 LC\_CTYPE=Chinese (Simplified)\_China.utf8 LC\_MONETARY=Chinese (Simplified)\_China.utf8  
[4] LC\_NUMERIC=C LC\_TIME=Chinese (Simplified)\_China.utf8

attached base packages:  
[1] stats graphics grDevices utils datasets methods base

other attached packages:  
[1] rstan\_2.21.7 ggplot2\_3.3.6 StanHeaders\_2.21.0-7 brms\_2.18.0 Rcpp\_1.0.9 readxl\_1.4.1

loaded via a namespace (and not attached):  
[1] nlme\_3.1-158 matrixStats\_0.62.0 xts\_0.12.1 threejs\_0.3.3 tensorA\_0.36.2 tools\_4.2.1 backports\_1.4.1  
[8] utf8\_1.2.2 R6\_2.5.1 DT\_0.25 metafor\_3.8-1 DBI\_1.1.3 colorspace\_2.0-3 withr\_2.5.0  
[15] tidyselect\_1.1.2 gridExtra\_2.3 prettyunits\_1.1.1 processx\_3.7.0 Brobdingnag\_1.2-7 compiler\_4.2.1 cli\_3.3.0  
[22] shinyjs\_2.1.0 colourpicker\_1.1.1 posterior\_1.3.1 scales\_1.2.1 dygraphs\_1.1.1.6 checkmate\_2.1.0 mvtnorm\_1.1-3  
[29] ggridges\_0.5.4 callr\_3.7.1 stringr\_1.4.0 digest\_0.6.29 base64enc\_0.1-3 pkgconfig\_2.0.3 htmltools\_0.5.3  
[36] fastmap\_1.1.0 htmlwidgets\_1.5.4 rlang\_1.0.5 rstudioapi\_0.13 shiny\_1.7.2 farver\_2.1.1 generics\_0.1.3  
[43] zoo\_1.8-10 crosstalk\_1.2.0 gtools\_3.9.3 dplyr\_1.0.10 distributional\_0.3.1 inline\_0.3.19 magrittr\_2.0.3  
[50] loo\_2.5.1 bayesplot\_1.9.0 metadat\_1.2-0 Matrix\_1.5-1 munsell\_0.5.0 fansi\_1.0.3 abind\_1.4-5  
[57] lifecycle\_1.0.2 stringi\_1.7.8 mathjaxr\_1.6-0 pkgbuild\_1.3.1 plyr\_1.8.7 grid\_4.2.1 parallel\_4.2.1  
[64] promises\_1.2.0.1 crayon\_1.5.1 miniUI\_0.1.1.1 lattice\_0.20-45 ps\_1.7.1 pillar\_1.8.1 igraph\_1.3.4  
[71] markdown\_1.1 shinystan\_2.6.0 reshape2\_1.4.4 codetools\_0.2-18 stats4\_4.2.1 rstantools\_2.2.0 glue\_1.6.2  
[78] RcppParallel\_5.1.5 vctrs\_0.4.1 httpuv\_1.6.6 cellranger\_1.1.0 gtable\_0.3.1 purrr\_0.3.4 assertthat\_0.2.1  
[85] mime\_0.12 xtable\_1.8-4 coda\_0.19-4 later\_1.3.0 tibble\_3.1.8 shinythemes\_1.2.0 ellipsis\_0.3.2  
[92] bridgesampling\_1.1-2

Operating System: Windows 11  
Compiler/Toolkit: rstan/rstudio

code：  
library(readxl)  
library(brms)  
dara\_choose ← read\_excel(“dara\_choose.xlsx”)  
dara\_choose$se\<-sqrt(dara\_choose$vi)  
m\_total = brm(data = dara\_choose,  
yi | se(se) ~ 1 + (1 | study/id))

output：  
Compiling Stan program…  
make cmd is  
make -f “E:/Learning Soft2/R-4.2.1/etc/x64/Makeconf” -f “E:/Learning Soft2/R-4.2.1/share/make/winshlib.mk” -f “C:/Users/aa271/Documents/.R/Makevars.win” CXX=‘(CXX14) (CXX14STD)’ CXXFLAGS=‘(CXX14FLAGS)' CXXPICFLAGS='(CXX14PICFLAGS)’ SHLIB\_LDFLAGS=‘(SHLIB\_CXX14LDFLAGS)' SHLIB\_LD='(SHLIB\_CXX14LD)’ SHLIB=“file6914638220d5.dll” WIN=64 TCLBIN= OBJECTS=“file6914638220d5.o”

make would use  
if test “zfile6914638220d5.o” != “z”; then   
if test -e “file6914638220d5-win.def”; then   
echo g++ -shared -s -static-libgcc -o file6914638220d5.dll file6914638220d5-win.def file6914638220d5.o -L"C:/rtools42/x86\_64-w64-mingw32.static.posix/lib/x64" -L"C:/rtools42/x86\_64-w64-mingw32.static.posix/lib" -L"E:/Learning Soft2/R-4.2.1/bin/x64" -lR ;   
g++ -shared -s -static-libgcc -o file6914638220d5.dll file6914638220d5-win.def file6914638220d5.o -L"C:/rtools42/x86\_64-w64-mingw32.static.posix/lib/x64" -L"C:/rtools42/x86\_64-w64-mingw32.static.posix/lib" -L"E:/Learning Soft2/R-4.2.1/bin/x64" -lR ;   
else   
echo EXPORTS \> tmp.def;   
nm file6914638220d5.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 file6914638220d5.dll tmp.def file6914638220d5.o -L"C:/rtools42/x86\_64-w64-mingw32.static.posix/lib/x64" -L"C:/rtools42/x86\_64-w64-mingw32.static.posix/lib" -L"E:/Learning Soft2/R-4.2.1/bin/x64" -lR ;   
g++ -shared -s -static-libgcc -o file6914638220d5.dll tmp.def file6914638220d5.o -L"C:/rtools42/x86\_64-w64-mingw32.static.posix/lib/x64" -L"C:/rtools42/x86\_64-w64-mingw32.static.posix/lib" -L"E:/Learning Soft2/R-4.2.1/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: file6914638220d5.o:file6914638220d5.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: file6914638220d5.o:file6914638220d5.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: file6914638220d5.o:file6914638220d5.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: file6914638220d5.o:file6914638220d5.cpp:(.text$\_ZN3tbb10interface  
Error in sink(type = “output”) : invalid connection

---

<div class="post-metadata">

**Author:** ![Ayin\_Ven](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.mc-stan.org/ayin_ven/32/15135_2.png) [@Ayin\_Ven](https://discourse.mc-stan.org/u/Ayin_Ven)\
**Post date:** [October 7, 2022, 4:14pm UTC](https://discourse.mc-stan.org/t/error-in-compilecode-f-code-language-language-verbose-verbose/29064/2 "2022-10-07T16:14:39Z")

</div>

code：example(stan\_model, package = “rstan”, run.dontrun = TRUE)

output：  
[output.txt](https://discourse.mc-stan.org/uploads/short-url/52J1A9oKC4a0oFJcj8FDoRciMo2.txt) (35.5 KB)

---

<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:** [October 7, 2022, 4:38pm UTC](https://discourse.mc-stan.org/t/error-in-compilecode-f-code-language-language-verbose-verbose/29064/3 "2022-10-07T16:38:08Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Ayin\_Ven](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.mc-stan.org/ayin_ven/32/15135_2.png) [@Ayin\_Ven](https://discourse.mc-stan.org/u/Ayin_Ven)\
**Post date:** [October 8, 2022, 5:04am UTC](https://discourse.mc-stan.org/t/error-in-compilecode-f-code-language-language-verbose-verbose/29064/5 "2022-10-08T05:04:50Z")

</div>

Hello, I ran these two pieces of code according to the GUIDE:

install.packages(“StanHeaders”, repos = c(“Repository for distributing (some) stan-dev R packages | r-packages”, getOption(“repos”)))  
install.packages(“rstan”, repos = c(“Repository for distributing (some) stan-dev R packages | r-packages”, getOption(“repos”)))

But it didn’t solve the problem, and the error still occurs：

# make cmd is make -f “E:/Learning Soft2/R-4.2.1/etc/x64/Makeconf” -f “E:/Learning Soft2/R-4.2.1/share/make/winshlib.mk” -f “C:/Users/aa271/Documents/.R/Makevars.win” CXX=‘ ( C X X 14 ) (CXX14STD)’ CXXFLAGS=‘ ( C X X 14 F L A G S ) ′ C X X P I C F L A G S

# ′ (CXX14PICFLAGS)’ SHLIB\_LDFLAGS=‘ ( S H L I B C X X 14 L D F L A G S ) ′ S H L I B L D

′  
(SHLIB\_CXX14LD)’ SHLIB=“file2d18202b3e76.dll” WIN=64 TCLBIN= OBJECTS=“file2d18202b3e76.o”

make would use  
if test “zfile2d18202b3e76.o” != “z”; then  
if test -e “file2d18202b3e76-win.def”; then  
echo g++ -shared -s -static-libgcc -o file2d18202b3e76.dll file2d18202b3e76-win.def file2d18202b3e76.o “E:/Learning Soft2/R-4.2.1/library/rstan/lib/x64/libStanServices.a” -L"E:/Learning Soft2/R-4.2.1/library/StanHeaders/libs/x64" -lStanHeaders -L"E:/Learning Soft2/R-4.2.1/library/RcppParallel/lib/x64" -ltbb -LE:/Learning Soft2/R-4.2.1/library/RcppParallel/lib/x64 -ltbb -ltbbmalloc -L"C:/rtools42/x86\_64-w64-mingw32.static.posix/lib/x64" -L"C:/rtools42/x86\_64-w64-mingw32.static.posix/lib" -L"E:/Learning Soft2/R-4.2.1/bin/x64" -lR ;  
g++ -shared -s -static-libgcc -o file2d18202b3e76.dll file2d18202b3e76-win.def file2d18202b3e76.o “E:/Learning Soft2/R-4.2.1/library/rstan/lib/x64/libStanServices.a” -L"E:/Learning Soft2/R-4.2.1/library/StanHeaders/libs/x64" -lStanHeaders -L"E:/Learning Soft2/R-4.2.1/library/RcppParallel/lib/x64" -ltbb -LE:/Learning Soft2/R-4.2.1/library/RcppParallel/lib/x64 -ltbb -ltbbmalloc -L"C:/rtools42/x86\_64-w64-mingw32.static.posix/lib/x64" -L"C:/rtools42/x86\_64-w64-mingw32.static.posix/lib" -L"E:/Learning Soft2/R-4.2.1/bin/x64" -lR ;  
else  
echo EXPORTS \> tmp.def;  
nm file2d18202b3e76.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 file2d18202b3e76.dll tmp.def file2d18202b3e76.o “E:/Learning Soft2/R-4.2.1/library/rstan/lib/x64/libStanServices.a” -L"E:/Learning Soft2/R-4.2.1/library/StanHeaders/libs/x64" -lStanHeaders -L"E:/Learning Soft2/R-4.2.1/library/RcppParallel/lib/x64" -ltbb -LE:/Learning Soft2/R-4.2.1/library/RcppParallel/lib/x64 -ltbb -ltbbmalloc -L"C:/rtools42/x86\_64-w64-mingw32.static.posix/lib/x64" -L"C:/rtools42/x86\_64-w64-mingw32.static.posix/lib" -L"E:/Learning Soft2/R-4.2.1/bin/x64" -lR ;  
g++ -shared -s -static-libgcc -o file2d18202b3e76.dll tmp.def file2d18202b3e76.o “E:/Learning Soft2/R-4.2.1/library/rstan/lib/x64/libStanServices.a” -L"E:/Learning Soft2/R-4.2.1/library/StanHeaders/libs/x64" -lStanHeaders -L"E:/Learning Soft2/R-4.2.1/library/RcppParallel/lib/x64" -ltbb -LE:/Learning Soft2/R-4.2.1/library/RcppParallel/lib/x64 -ltbb -ltbbmalloc -L"C:/rtools42/x86\_64-w64-mingw32.static.posix/lib/x64" -L"C:/rtools42/x86\_64-w64-mingw32.static.posix/lib" -L"E:/Learning Soft2/R-4.2.1/bin/x64" -lR ;  
rm -f tmp.def;  
fi  
fi  
Error in compileCode(f, code, language = language, verbose = verbose) :  
E:/Learning Soft2/R-4.2.1/library/RcppEigen/include/Eigen/src/Core/ProductEvaluators.h:35:90: required from 'Eigen::internal::evaluator\<Eigen::Product\<Lhs, Rhs, Option\> \>::evaluator(const XprType&) [with Lhs = Eigen::Product\<Eigen::CwiseBinaryOp\<Eigen::internal::scalar\_product\_op\<double, double\>, const Eigen::CwiseNullaryOp\<Eigen::internal::scalar\_constant\_op, const Eigen::Matrix\<double, 1, -1\> \>, const Eigen::Transpose\<Eigen::Matrix\<double, -1, 1\> \> \>, Eigen::Matrix\<double, -1, -1\>, 0\>; Rhs = Eigen::Matrix\<double, -1, 1\>; int Options = 0; Eigen::internal::evaluator\<Eigen::Product\<Lhs, Rhs, Option\> \>::XprType = Eigen::Product\<Eigen::Product\<Eigen::CwiseBinaryOp\<Eigen::internal::scalar\_product\_op\<double, double\>, const Eigen::CwiseNullaryOp\<Eigen::internal::scalar\_constant\_op, const Eigen::Matrix\<double, 1, -1\> \>, const Eigen::Transpose\<Eigen::Matrix\<double, -1, 1\> \> \>, Eigen::Matrix\<double, -1, -1\>, 0\>, Eigen::Matrix\<double, -1, 1\>, 0\>]'E:/Learning Soft2/R-4.  
Error in sink(type = “output”) : invalid connection

---

<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:** [October 8, 2022, 12:30pm UTC](https://discourse.mc-stan.org/t/error-in-compilecode-f-code-language-language-verbose-verbose/29064/6 "2022-10-08T12:30:53Z")

</div>

Can you post the output from the following commands:

```r
devtools::session_info("rstan")
example(stan_model, package ="rstan", run.dontrun=T, verbose=T)

```

---

<div class="post-metadata">

**Author:** ![Ayin\_Ven](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.mc-stan.org/ayin_ven/32/15135_2.png) [@Ayin\_Ven](https://discourse.mc-stan.org/u/Ayin_Ven)\
**Post date:** [October 8, 2022, 4:33pm UTC](https://discourse.mc-stan.org/t/error-in-compilecode-f-code-language-language-verbose-verbose/29064/7 "2022-10-08T16:33:26Z")

</div>

Thanks.  
But the problem was solved when I retired the version of R to 4.1.3.It may have something to do with the version of R.  
The error is still reported in version 4.2

CODE:  
devtools::session\_info(“rstan”)  
example(stan\_model, package =“rstan”, run.dontrun=T, verbose=T)  
[output.txt](https://discourse.mc-stan.org/uploads/short-url/uEHF0izZ1VGZeJSxRqA0LndvzFv.txt) (51.9 KB)
