# Compiling error

**URL:** <https://discourse.mc-stan.org/t/compiling-error/7978>\
**Category:** General\
**Created:** [March 8, 2019, 12:34pm UTC](https://discourse.mc-stan.org/t/compiling-error/7978 "2019-03-08T12:34:26Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Bird](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.mc-stan.org/bird/32/4497_2.png) [@Bird](https://discourse.mc-stan.org/u/Bird)\
**Post date:** [March 8, 2019, 12:34pm UTC](https://discourse.mc-stan.org/t/compiling-error/7978/1 "2019-03-08T12:34:26Z")

</div>

**Hello,**

**After trying to fit this model:**  
**xbayes ← brm(y ~ x, mytib)**

**I am getting this error:**

Compiling the C++ model  
Error in compileCode(f, code, language = language, verbose = verbose) :  
Compilation ERROR, function(s)/method(s) not created! In file included from file12e812ef45c72.cpp:8:  
In file included from /Library/Frameworks/R.framework/Versions/3.5/Resources/library/StanHeaders/include/src/stan/model/model\_header.hpp:4:  
In file included from /Library/Frameworks/R.framework/Versions/3.5/Resources/library/StanHeaders/include/stan/math.hpp:4:  
In file included from /Library/Frameworks/R.framework/Versions/3.5/Resources/library/StanHeaders/include/stan/math/rev/mat.hpp:4:  
In file included from /Library/Frameworks/R.framework/Versions/3.5/Resources/library/StanHeaders/include/stan/math/rev/core.hpp:4:  
In file included from /Library/Frameworks/R.framework/Versions/3.5/Resources/library/StanHeaders/include/stan/math/rev/core/autodiffstackstorage.hpp:4:  
In file included from /Library/Frameworks/R.framework/Versions/3.5/Resources/library/StanHeaders/include/stan/math/memory/stack\_alloc.hpp:8:  
In file included from /usr/local/clang4/bin/…/include/c++/v1/cstdlib:86:  
In addition: Warning message:  
In system(cmd, intern = !verbose) :

Error in compileCode(f, code, language = language, verbose = verbose) :  
Compilation ERROR, function(s)/method(s) not created! In file included from file12e812ef45c72.cpp:8:  
In file included from /Library/Frameworks/R.framework/Versions/3.5/Resources/library/StanHeaders/include/src/stan/model/model\_header.hpp:4:  
In file included from /Library/Frameworks/R.framework/Versions/3.5/Resources/library/StanHeaders/include/stan/math.hpp:4:  
In file included from /Library/Frameworks/R.framework/Versions/3.5/Resources/library/StanHeaders/include/stan/math/rev/mat.hpp:4:  
In file included from /Library/Frameworks/R.framework/Versions/3.5/Resources/library/StanHeaders/include/stan/math/rev/core.hpp:4:  
In file included from /Library/Frameworks/R.framework/Versions/3.5/Resources/library/StanHeaders/include/stan/math/rev/core/autodiffstackstorage.hpp:4:  
In file included from /Library/Frameworks/R.framework/Versions/3.5/Resources/library/StanHeaders/include/stan/math/memory/stack\_alloc.hpp:8:  
In file included from /usr/local/clang4/bin/…/include/c++/v1/cstdlib:86:  
Error in sink(type = “output”) : invalid connection

**I did this and I got 10:**

fx ← inline::cxxfunction( signature(x = “integer”, y = “numeric” ) , ’  
return ScalarReal( INTEGER(x)[0] \* REAL(y)[0] ) ;  
’ )  
fx( 2L, 5 ) # should be 10

**Here is more information:**

> sessionInfo()  
> R version 3.5.2 (2018-12-20)  
> Platform: x86\_64-apple-darwin15.6.0 (64-bit)  
> Running under: macOS Mojave 10.14

I have Xtools 10 installed.  
rstan 2.18.2  
rstantools 1.5.1

Thank you very much!

---

<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:** [March 8, 2019, 3:08pm UTC](https://discourse.mc-stan.org/t/compiling-error/7978/2 "2019-03-08T15:08:02Z")

</div>

Try

```
stancode <- 'data {real y_mean;} parameters {real y;} model {y ~ normal(y_mean,1);}'
mod <- stan_model(model_code = stancode, verbose = TRUE)

```

and tell us what is the string involving `error:` (with the colon).

---

<div class="post-metadata">

**Author:** ![Bird](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.mc-stan.org/bird/32/4497_2.png) [@Bird](https://discourse.mc-stan.org/u/Bird)\
**Post date:** [March 8, 2019, 3:19pm UTC](https://discourse.mc-stan.org/t/compiling-error/7978/3 "2019-03-08T15:19:23Z")

</div>

This one:

In file included from /usr/local/clang4/bin/…/include/c++/v1/cstdlib:86:  
/usr/local/clang4/bin/…/include/c++/v1/stdlib.h:94:15: fatal error: ‘stdlib.h’ file not found

---

<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:** [March 8, 2019, 3:21pm UTC](https://discourse.mc-stan.org/t/compiling-error/7978/4 "2019-03-08T15:21:25Z")

</div>

> [@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:** ![Bird](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.mc-stan.org/bird/32/4497_2.png) [@Bird](https://discourse.mc-stan.org/u/Bird)\
**Post date:** [March 9, 2019, 3:21pm UTC](https://discourse.mc-stan.org/t/compiling-error/7978/5 "2019-03-09T15:21:19Z")

</div>

I really appreciate your help, but I feel like you’re speaking Russian to me (I don’t speak Russian). I am a psychologist, not a programmer/developer, and I’m getting more confused. I tried the first option and did not work.

I followed this path:  
/Library/Developer/CommandLineTools/Packages/

and the only thing I found is a folder called usr which only contains another one called share.

I do not know how to rename / delete / empty the ~/.R/Makevars either :(

---

<div class="post-metadata">

**Author:** ![Bird](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.mc-stan.org/bird/32/4497_2.png) [@Bird](https://discourse.mc-stan.org/u/Bird)\
**Post date:** [March 9, 2019, 6:17pm UTC](https://discourse.mc-stan.org/t/compiling-error/7978/6 "2019-03-09T18:17:15Z")

</div>

Hi again,

I updated Mojave, and reinstalled Xcode. I got the latest version (10.2 beta 4). Now the error I’m getting is this:

Compiling the C++ model  
running command ‘’/Library/Frameworks/R.framework/Resources/bin/R’ CMD config CXX14 2\>/dev/null’ had status 1Error in if (nchar(CXX) == 0) { : argument is of length zero

^bangs head against table in frustration^

---

<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:** [March 9, 2019, 7:55pm UTC](https://discourse.mc-stan.org/t/compiling-error/7978/7 "2019-03-09T19:55:50Z")

</div>

Make sure you have accepted the license agreement for Xcode by opening it once via Spotlight. Then tell us what

```
pkgbuild::has_build_tools(debug = TRUE)

```

says.
