schwehr / libais

C++ decoder for Automatic Identification System for tracking ships and decoding maritime information
Other
215 stars 94 forks source link

install fails on OSX (python 3.6) #184

Closed loicpw closed 5 years ago

loicpw commented 5 years ago

Hi, I have troubles on OSX when trying to install libais in a venv (haven't tried another way), the compiler cannot find the standard libraries (looks like the default is not supported on OSX).

/usr/bin/clang -fno-strict-aliasing -Wsign-compare -fno-common -dynamic -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -arch i386 -arch x86_64 -g -I/Users/XXXXX/venv/include -I/Library/Frameworks/Python.framework/Versions/3.6/include/python3.6m -c src/libais/ais_py.cpp -o build/temp.macosx-10.6-intel-3.6/src/libais/ais_py.o -std=c++11
    In file included from src/libais/ais_py.cpp:6:
    src/libais/ais.h:8:10: fatal error: 'array' file not found
    #include <array>
             ^~~~~~~

so I need to specify -stdlib=libc++, it works if I install it using setup.py as follows:

EXTRA_COMPILE_ARGS = []
if sys.platform in ('darwin', 'linux', 'linux2'):
  EXTRA_COMPILE_ARGS = ['-std=c++11']
if sys.platform == 'darwin':
  EXTRA_COMPILE_ARGS.append('-stdlib=libc++')

I also need to set MACOSX_DEPLOYMENT_TARGET=10.7 or it fails with invalid deployment target for -stdlib=libc++ (requires OS X 10.7 or later)

details: 16.7.0 Darwin Kernel Version 16.7.0 [...] RELEASE_X86_64 x86_64 Python 3.6.4

Thanks

EDIT:

Well sorry I was using clang and should have used gcc, a better solution then:

brew install gcc
CC=gcc-8 CXX=g++-8 pip install libais
alexvoronov commented 5 years ago

Thanks @loicpw for posting the solution! I also struggled with installing libais on macOS, and CC=gcc-8 CXX=g++-8 pip install libais worked!