# Compiling Stan program... block

**URL:** <https://discourse.mc-stan.org/t/compiling-stan-program-block/17827>\
**Category:** Modeling\
**Created:** [September 3, 2020, 9:01am UTC](https://discourse.mc-stan.org/t/compiling-stan-program-block/17827 "2020-09-03T09:01:42Z")\
**Posts on this page:** 1\
**Showing post:** 8

<div class="post-metadata">

**Author:** ![jonah](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.mc-stan.org/jonah/32/200_2.png) [@jonah](https://discourse.mc-stan.org/u/jonah)\
**Post date:** [September 4, 2020, 7:13pm UTC](https://discourse.mc-stan.org/t/compiling-stan-program-block/17827/8 "2020-09-04T19:13:33Z")

</div>

Unfortunately it’s pretty hard right now to get it working with R 3.6 on Mac. It seems to require installing a bunch of packages from source (probably at least Rcpp, StanHeaders, RStan) and I’m not even sure what Makevars settings are required. @bgoodri do you know?

By far the easiest solution is to install the latest version of R (probably a good idea anyway) and use the following lines in the Makevars file:

```
# use file.edit(file.path(Sys.getenv("HOME"), ".R", "Makevars")) 
# to edit the file and give it these contents: 

CXX14FLAGS=-O3 -march=native -mtune=native 
CXX14FLAGS += -arch x86_64 -ftemplate-depth-256

```

I haven’t seen any examples where R 4.0.2 combined with that Makevars file fails on Mac (unless you get an error like [Some models run without problems, but more complex give error: Error in unserialize(socklist[[n]]) : error reading/writing from connection](https://discourse.mc-stan.org/t/some-models-run-without-problems-but-more-complex-give-error-error-in-unserialize-socklist-n-error-reading-writing-from-connection/17298/12), in which case @torkar mentioned that removing `-march=native` can solve that on Mac).

---

_[View the full topic](https://discourse.mc-stan.org/t/compiling-stan-program-block/17827)._
