From 9890bbb32317457b31077c651d43a3ef6926ef37 Mon Sep 17 00:00:00 2001 From: Luca Dorigo Date: Mon, 22 Apr 2019 21:56:17 +0200 Subject: [PATCH] Made compatible with macOS mojave After a 10hour-long fight I finally found how to make this work with macOS Mojave. Since apple deprecated stdlibc++, it is necessary to pass the extra argument "-stdlib=libc++" to both the compiler and the linker. Furthermore, as is the case in https://github.com/chokkan/crfsuite/issues/11, I modified the libraries given to the linker. --- setup.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/setup.py b/setup.py index ff198c6..d898a50 100644 --- a/setup.py +++ b/setup.py @@ -59,6 +59,13 @@ def get_swigdir(): # need iconv too but without proper -L adding -liconv here won't always work libs = [] +if sys.platform.startswith("darwin"): + # On recent macos versions (mojave) it is necessary to specify that libc++ is used instead of libstdc++. + # Furthermore, '-Wl,-undefined,dynamic_lookup' is necessary to link the right libraries. + libs += ["-stdlib=libc++", '-Wl,-undefined,dynamic_lookup'] + extra_compile_args = ["-stdlib=libc++"] + + simstring_module = Extension( '_simstring', sources = [