# Error in compile Code

**URL:** <https://discourse.mc-stan.org/t/error-in-compile-code/32046>\
**Category:** Modeling\
**Tags:** rstan\
**Created:** [July 11, 2023, 5:05pm UTC](https://discourse.mc-stan.org/t/error-in-compile-code/32046 "2023-07-11T17:05:46Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![rose980829](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.mc-stan.org/rose980829/32/16647_2.png) [@rose980829](https://discourse.mc-stan.org/u/rose980829)\
**Post date:** [July 11, 2023, 5:05pm UTC](https://discourse.mc-stan.org/t/error-in-compile-code/32046/1 "2023-07-11T17:05:46Z")

</div>

This is my error code

> Error in compileCode(f, code, language = language, verbose = verbose) :  
> C:\rtools43\x86\_64-w64-mingw32.static.posix\bin/ld.exe: file1fcfc21cd39c9.o:file1fcfc21cd39c9.cpp:(.text$\_ZN3tbb8internal26task\_scheduler\_observer\_v3D0Ev[\_ZN3tbb8internal26task\_scheduler\_observer\_v3D0Ev]+0x1c): undefined reference to `tbb::internal::task_scheduler_observer_v3::observe(bool)'C:\rtools43\x86_64-w64-mingw32.static.posix\bin/ld.exe: file1fcfc21cd39c9.o:file1fcfc21cd39c9.cpp:(.text$_ZN3tbb10interface623task_scheduler_observerD1Ev[_ZN3tbb10interface623task_scheduler_observerD1Ev]+0x1c): undefined reference to `tbb::internal::task\_scheduler\_observer\_v3::observe(bool)'C:\rtools43\x86\_64-w64-mingw32.static.posix\bin/ld.exe: file1fcfc21cd39c9.o:file1fcfc21cd39c9.cpp:(.text$\_ZN3tbb10interface623task\_scheduler\_observerD1Ev[\_ZN3tbb10interface623task\_scheduler\_observerD1Ev]+0x37): undefined reference to `tbb::internal::task\_scheduler\_observer\_v3::observe(bool)'C:\rtools43\x86\_64-w64-mingw32.static.posix\bin/ld.exe: file1fcfc21cd39c9.o:file1fcfc21cd39c9.cpp:(.text$\_ZN3tbb10i  
> Error in sink(type = “output”) : invalid connection

The Rstudio code part that making error is

```no-highlight
 #run MCMC called from STAN code
eivModel.fit = stan(file = "/Users/jeongsiklim/R code/mcmc_poly2_dark_ratio.stan",
                    data = eivModel.data,
                    control = list(adapt_delta=0.985, max_treedepth=12),
                    #warmup = 1000000, 
                    iter = 5000000,
                    chains=4, cores = 4, thin = 15)

print(eivModel.fit, digits=5)

```

And stan code is

```no-highlight

data {
  int n ; // number of measruement result
    vector<lower=0>[n] x ; // horizontal (reference)
	vector<lower=0>[n] ux ; // Std. unc. for horizontal
	vector<lower=0>[n] y ; // vertical (response) 
    vector<lower=0>[n] uy ; // Std. unc. for vertical
    vector[3] betaM ; // Prior means for betas
 	vector<lower=0>[3] betaS ; // Prior SDs for betas
 	vector<lower=0>[n] rhoM ;	// Prior means for rhos (vertical)
 	vector<lower=0>[n] rhoS ;	// Prior mSDs for rhos
 	real<lower=0> gammay ; // Prior median for dark uncertainty along horizontal
 }		 

parameters {
	vector[3] beta ; // Regression coefficients
	vector<lower=0>[n] rho ; // unobservable true values of vertical 
	real<lower=0> tauy ; // Dark uncertainty in vertical
}		 
	
transformed parameters {
	vector<lower=0>[n] rhoi ; // Mean values of amount fractions
	for (j in 1:n) {rhoi[j] = beta[1] + beta[2]*x[j] + beta[3]*x[j]^2;} //
}	

model {
	beta ~ normal(betaM, betaS) ; // Prior for betas
	tauy ~ cauchy(0, gammay) ; // Prior for dark uncertainty of response
	rho ~ normal(rhoM, rhoS) ; // Prior for rhos
	y ~ normal(rhoi, sqrt(square(uy) + square(tauy))) ; // Likelihood for vertical (response) 
	x ~ normal(x, ux) ; // Likelihood for horizontal (reference)
}

```

I installed R, Rstudio, Rtools, and ‘rstan’ packages all new version.  
The file path is all correct.

I want to know how to make this work.

Thank you.

edited by @jsocolar to remove boilerplate

---

<div class="post-metadata">

**Author:** ![bmfazio](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.mc-stan.org/bmfazio/32/16653_2.png) [@bmfazio](https://discourse.mc-stan.org/u/bmfazio)\
**Post date:** [July 12, 2023, 8:28am UTC](https://discourse.mc-stan.org/t/error-in-compile-code/32046/2 "2023-07-12T08:28:21Z")

</div>

I have seen many users reporting such a problem with the current CRAN release of `rstan` (v2.21), but it appears to be fixed in the current development version (2.26). See the link below for instructions on how to install it.

> **[RStan Getting Started](https://github.com/stan-dev/rstan/wiki/RStan-Getting-Started)**
>
> RStan, the R interface to Stan. Contribute to stan-dev/rstan development by creating an account on GitHub.
