diff --git a/cython/gtsam/setup.py.in b/cython/gtsam/setup.py.in index 043df6b77..59af17c3c 100644 --- a/cython/gtsam/setup.py.in +++ b/cython/gtsam/setup.py.in @@ -2,6 +2,12 @@ from distutils.core import setup from distutils.extension import Extension from Cython.Build import cythonize import eigency +from sys import platform + +# force clang use libc++ instead of the default libstdc++ shipped with MacOSX, which doesn't support c++11 +libc_flag = [] +if platform == "darwin": + libc_flag = ["-stdlib=libc++"] setup( ext_modules = cythonize(Extension( @@ -13,5 +19,6 @@ setup( libraries = ['gtsam'], library_dirs = ["${CMAKE_BINARY_DIR}/gtsam"], language="c++", - extra_compile_args=["-std=c++11"])), -) \ No newline at end of file + extra_compile_args=["-std=c++11"] + libc_flag, + extra_link_args=libc_flag)), +) diff --git a/cython/gtsam_unstable/setup.py.in b/cython/gtsam_unstable/setup.py.in index 2fdad076d..548802c67 100644 --- a/cython/gtsam_unstable/setup.py.in +++ b/cython/gtsam_unstable/setup.py.in @@ -7,6 +7,10 @@ import sys # so that it can find the wrapped gtsam package sys.path.append("..") +libc_flag = [] +if sys.platform == "darwin": + libc_flag = ["-stdlib=libc++"] + setup( ext_modules=cythonize(Extension( "gtsam_unstable", @@ -17,6 +21,7 @@ setup( libraries=['gtsam', 'gtsam_unstable'], library_dirs=["${GTSAM_DIR}/../../"], language="c++", - extra_compile_args=["-std=c++11"])), + extra_compile_args=["-std=c++11"] + libc_flag, + extra_link_args=libc_flag)), )