# Compile error on MacOS and Pystan

**URL:** <https://discourse.mc-stan.org/t/compile-error-on-macos-and-pystan/16238>\
**Category:** PyStan\
**Created:** [June 26, 2020, 9:56pm UTC](https://discourse.mc-stan.org/t/compile-error-on-macos-and-pystan/16238 "2020-06-26T21:56:32Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![ptonner](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.mc-stan.org/ptonner/32/8466_2.png) [@ptonner](https://discourse.mc-stan.org/u/ptonner)\
**Post date:** [June 26, 2020, 9:56pm UTC](https://discourse.mc-stan.org/t/compile-error-on-macos-and-pystan/16238/1 "2020-06-26T21:56:32Z")

</div>

Getting a compilation error with pystan on MacOS, doesn’t appear to be the same as others already described.

- OSX 10.15.15
- pystan 2.19.1.1
- python 3.7
- using (or attempting to use) the anaconda compiler
- already installed xcode with “xcode-select install”

Following the [instructions here](https://github.com/stan-dev/pystan/blob/develop/doc/installation_beginner.rst)

What I believe is the relevant compiler output, in particular the “ld: unknown option: -platform\_version”:

> x86\_64-apple-darwin13.4.0-clang++ -bundle -undefined dynamic\_lookup -Wl,-pie -Wl,-headerpad\_max\_install\_names -Wl,-dead\_strip\_dylibs -Wl,-rpath,/Users/pdt2/o  
> pt/anaconda3/envs/phenom/lib -L/Users/pdt2/opt/anaconda3/envs/phenom/lib -flto -Wl,-export\_dynamic -Wl,-pie -Wl,-headerpad\_max\_install\_names -Wl,-dead\_strip\_  
> dylibs -Wl,-rpath,/Users/pdt2/opt/anaconda3/envs/phenom/lib -L/Users/pdt2/opt/anaconda3/envs/phenom/lib -Wl,-pie -Wl,-headerpad\_max\_install\_names -Wl,-dead\_s  
> trip\_dylibs -Wl,-rpath,/Users/pdt2/opt/anaconda3/envs/phenom/lib -L/Users/pdt2/opt/anaconda3/envs/phenom/lib -march=core2 -mtune=haswell -mssse3 -ftree-vecto  
> rize -fPIC -fPIE -fstack-protector-strong -O2 -pipe -isystem /Users/pdt2/opt/anaconda3/envs/phenom/include -D\_FORTIFY\_SOURCE=2 -mmacosx-version-min=10.9 -isy  
> stem /Users/pdt2/opt/anaconda3/envs/phenom/include -arch x86\_64 /var/folders/cz/7j2rv40n30z87t2fq2c51vrh001wdz/T/pystan\_amcoits0/var/folders/cz/7j2rv40n30z87  
> t2fq2c51vrh001wdz/T/pystan\_amcoits0/stanfit4anon\_model\_5944b02c79788fa0db5b3a93728ca2bf\_5600958195541983510.o -o /var/folders/cz/7j2rv40n30z87t2fq2c51vrh001w  
> dz/T/pystan\_amcoits0/stanfit4anon\_model\_5944b02c79788fa0db5b3a93728ca2bf\_5600958195541983510.cpython-37m-darwin.so  
> ld: unknown option: -platform\_version  
> clang-10: error: linker command failed with exit code 1 (use -v to see invocation)  
> Traceback (most recent call last):  
> File “/Users/pdt2/opt/anaconda3/envs/phenom/lib/python3.7/distutils/unixccompiler.py”, line 205, in link  
> self.spawn(linker + ld\_args)  
> File “/Users/pdt2/opt/anaconda3/envs/phenom/lib/python3.7/distutils/ccompiler.py”, line 910, in spawn  
> spawn(cmd, dry\_run=self.dry\_run)  
> File “/Users/pdt2/opt/anaconda3/envs/phenom/lib/python3.7/distutils/spawn.py”, line 36, in spawn  
> \_spawn\_posix(cmd, search\_path, dry\_run=dry\_run)  
> File “/Users/pdt2/opt/anaconda3/envs/phenom/lib/python3.7/distutils/spawn.py”, line 159, in \_spawn\_posix  
> % (cmd, exit\_status))  
> distutils.errors.DistutilsExecError: command ‘x86\_64-apple-darwin13.4.0-clang++’ failed with exit status 1

---

<div class="post-metadata">

**Author:** ![ptonner](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.mc-stan.org/ptonner/32/8466_2.png) [@ptonner](https://discourse.mc-stan.org/u/ptonner)\
**Post date:** [June 26, 2020, 10:05pm UTC](https://discourse.mc-stan.org/t/compile-error-on-macos-and-pystan/16238/2 "2020-06-26T22:05:34Z")

</div>

[This answer](https://stackoverflow.com/a/61103105) indicated that a compiler flag can help, but I’m not sure how to accomplish that with stan compilation

---

<div class="post-metadata">

**Author:** ![ahartikainen](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.mc-stan.org/ahartikainen/32/321_2.png) [@ahartikainen](https://discourse.mc-stan.org/u/ahartikainen)\
**Post date:** [June 27, 2020, 7:18am UTC](https://discourse.mc-stan.org/t/compile-error-on-macos-and-pystan/16238/3 "2020-06-27T07:18:04Z")

</div>

Do you have both xcode compiler and anaconda compiler?

Maybe this is something similar as in `libc++` vs `libstdc++`.

What happens if you try to compile with xcode?

---

<div class="post-metadata">

**Author:** ![ahartikainen](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.mc-stan.org/ahartikainen/32/321_2.png) [@ahartikainen](https://discourse.mc-stan.org/u/ahartikainen)\
**Post date:** [June 27, 2020, 7:19am UTC](https://discourse.mc-stan.org/t/compile-error-on-macos-and-pystan/16238/4 "2020-06-27T07:19:40Z")

</div>

And,

currently, there probably isn’t a way to add `extra_link_args` (but it goes to same location as does `extra_compile_args`).

---

<div class="post-metadata">

**Author:** ![ptonner](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.mc-stan.org/ptonner/32/8466_2.png) [@ptonner](https://discourse.mc-stan.org/u/ptonner)\
**Post date:** [June 27, 2020, 10:38pm UTC](https://discourse.mc-stan.org/t/compile-error-on-macos-and-pystan/16238/5 "2020-06-27T22:38:33Z")

</div>

Thanks for the fast reply! Solution was to update Xcode - duh!
