Compile error on MacOS and Pystan

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

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

This answer indicated that a compiler flag can help, but I’m not sure how to accomplish that with stan compilation

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?

And,

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

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