# Compilation error (rstan)

**URL:** <https://discourse.mc-stan.org/t/compilation-error-rstan/9502>\
**Category:** General\
**Created:** [July 2, 2019, 7:03pm UTC](https://discourse.mc-stan.org/t/compilation-error-rstan/9502 "2019-07-02T19:03:39Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Jianjiu\_Chen](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.mc-stan.org/jianjiu_chen/32/5262_2.png) [@Jianjiu\_Chen](https://discourse.mc-stan.org/u/Jianjiu_Chen)\
**Post date:** [July 2, 2019, 7:03pm UTC](https://discourse.mc-stan.org/t/compilation-error-rstan/9502/1 "2019-07-02T19:03:39Z")

</div>

Hi,

I am trying to use rstan for bayesian inference in a modeling study in public health. I stored the model definition in a character string in R, and called stan() function, as below:

fit1 \<- stan(model\_code = s, data = d\_list)

However, an error occurred with details at the end this post. I actually tried the Eight schools example, and got exactly the same error message. I don’t have a background in computer science, and am quite confused with this problem. I will greatly appreciate it if someone can help.

Thanks a lot in advance!  
Jianjiu

Error in compileCode(f, code, language = language, verbose = verbose) :  
Compilation ERROR, function(s)/method(s) not created! clang: warning: no such sysroot directory: ‘/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk’ [-Wmissing-sysroot]  
In file included from file2f55c94c67a.cpp:8:  
In file included from /Library/Frameworks/R.framework/Versions/3.6/Resources/library/StanHeaders/include/src/stan/model/model\_header.hpp:4:  
In file included from /Library/Frameworks/R.framework/Versions/3.6/Resources/library/StanHeaders/include/stan/math.hpp:4:  
In file included from /Library/Frameworks/R.framework/Versions/3.6/Resources/library/StanHeaders/include/stan/math/rev/mat.hpp:4:  
In file included from /Library/Frameworks/R.framework/Versions/3.6/Resources/library/StanHeaders/include/stan/math/rev/core.hpp:4:  
In file included from /Library/Frameworks/R.framework/Versions/3.6/Resources/library/StanHeaders/include/stan/math/rev/core/autodiffstackstorage.hpp:4:  
In file included from /Library/Frameworks/R.framework/Versions/3.6/Resources/library/StanHeaders/in  
In addition: Warning message:  
In system(cmd, intern = !verbose) :  
running command ‘/Library/Frameworks/R.framework/Resources/bin/R CMD SHLIB file2f55c94c67a.cpp 2\> file2f55c94c67a.cpp.err.txt’ had status 1  
Error in sink(type = “output”) : invalid connection

---

<div class="post-metadata">

**Author:** ![bgoodri](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.mc-stan.org/bgoodri/32/4451_2.png) [@bgoodri](https://discourse.mc-stan.org/u/bgoodri)\
**Post date:** [July 2, 2019, 11:04pm UTC](https://discourse.mc-stan.org/t/compilation-error-rstan/9502/2 "2019-07-02T23:04:53Z")

</div>

Most likely something from below will work.

> [@Dealing with Mojave](https://discourse.mc-stan.org/t/dealing-with-mojave/6519):
>
> For the first time, getting rstan to work on Windows seems to be easier than getting it to work on the Mojave version Mac OS X. Mojave seems to affect different people in different ways. Here are the things I would try if rstan is not working: Make sure you have opened Xcode once via Spotlight to accept its license If that doesn’t work but you have a /Library/Developer/CommandLineTools/Packages/macOS\_SDK\_headers\_for\_macOS\_10.14. pkg, install that so it puts C++ headers back in /usr/include I…

---

<div class="post-metadata">

**Author:** ![Jianjiu\_Chen](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.mc-stan.org/jianjiu_chen/32/5262_2.png) [@Jianjiu\_Chen](https://discourse.mc-stan.org/u/Jianjiu_Chen)\
**Post date:** [July 3, 2019, 3:05pm UTC](https://discourse.mc-stan.org/t/compilation-error-rstan/9502/3 "2019-07-03T15:05:55Z")

</div>

Thank you so much!

In my case, I tried 1, which did not work. I am not sure how to do 2-4; but after I tried 5, the compilation worked, and results were produced.

Best wishes  
Jianjiu
