Missing arguments to linker on OS X/llvm
molpopgen opened this issue · 2 comments
molpopgen commented
On OS X, the -stdlib and min os x version passed to CPPFLAGS here:
https://github.com/pybind/python_example/blob/master/setup.py#L75
should also be added to the equivalent to LDFLAGS on Unix systems. I believe that is extra_linker_args?
If this is not done, odd symptoms happen like exceptions not propagating from C++ to Python as expected, etc.
cdeil commented
I think this official pybind11 python_example is broken on macOS with recent clang?
Would be great to have a working example of pybind11 without requiring cmake. I looked around today and couldn't find one. Or is use of pybind 11 only with CMake the recommended way?
cc @henryiii @HDembinski @SylvainCorlay
I get this:
(school19) hfm-1804a:python_example deil$ clang --version
Apple LLVM version 10.0.1 (clang-1001.0.46.3)
Target: x86_64-apple-darwin18.5.0
Thread model: posix
InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin
(school19) hfm-1804a:python_example deil$ python setup.py build_ext -i
running build_ext
gcc -Wno-unused-result -Wsign-compare -Wunreachable-code -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -I/Users/deil/software/anaconda3/envs/school19/include -arch x86_64 -I/Users/deil/software/anaconda3/envs/school19/include -arch x86_64 -I/Users/deil/software/anaconda3/envs/school19/include/python3.6m -c /var/folders/t_/_mywtcj146lbk2c99bnxw7z40000gp/T/tmpwi2ht3ex.cpp -o var/folders/t_/_mywtcj146lbk2c99bnxw7z40000gp/T/tmpwi2ht3ex.o -std=c++14
warning: include path for stdlibc++ headers not found; pass '-stdlib=libc++' on the command line to use the libc++ standard library instead [-Wstdlibcxx-not-found]
1 warning generated.
gcc -Wno-unused-result -Wsign-compare -Wunreachable-code -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -I/Users/deil/software/anaconda3/envs/school19/include -arch x86_64 -I/Users/deil/software/anaconda3/envs/school19/include -arch x86_64 -I/Users/deil/software/anaconda3/envs/school19/include/python3.6m -c /var/folders/t_/_mywtcj146lbk2c99bnxw7z40000gp/T/tmpmdshpn7n.cpp -o var/folders/t_/_mywtcj146lbk2c99bnxw7z40000gp/T/tmpmdshpn7n.o -fvisibility=hidden
warning: include path for stdlibc++ headers not found; pass '-stdlib=libc++' on the command line to use the libc++ standard library instead [-Wstdlibcxx-not-found]
1 warning generated.
building 'python_example' extension
gcc -Wno-unused-result -Wsign-compare -Wunreachable-code -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -I/Users/deil/software/anaconda3/envs/school19/include -arch x86_64 -I/Users/deil/software/anaconda3/envs/school19/include -arch x86_64 -I/Users/deil/software/anaconda3/envs/school19/include/python3.6m -I/Users/deil/.local/include/python3.6m -I/Users/deil/software/anaconda3/envs/school19/include/python3.6m -c src/main.cpp -o build/temp.macosx-10.7-x86_64-3.6/src/main.o -stdlib=libc++ -mmacosx-version-min=10.7 -DVERSION_INFO="0.0.1" -std=c++14 -fvisibility=hidden
g++ -bundle -undefined dynamic_lookup -L/Users/deil/software/anaconda3/envs/school19/lib -arch x86_64 -L/Users/deil/software/anaconda3/envs/school19/lib -arch x86_64 -arch x86_64 build/temp.macosx-10.7-x86_64-3.6/src/main.o -o build/lib.macosx-10.7-x86_64-3.6/python_example.cpython-36m-darwin.so
clang: warning: libstdc++ is deprecated; move to libc++ with a minimum deployment target of OS X 10.9 [-Wdeprecated]
ld: library not found for -lstdc++
clang: error: linker command failed with exit code 1 (use -v to see invocation)
error: command 'g++' failed with exit status 1
wjakob commented
Should be fixed now.