Skip to content

Failed compiling on MacOS with C++17 flags #48

@guyarad

Description

@guyarad

When attempting to install the example, the build fails with the error below.
After manually removing the C++17 flag option (I suppose C++14 was selected then) the install was successful. Can you share what I was doing wrong?

System information:
MacOS Mojave 10.14.6
Python 3.8.0
Clang compiler information:
Apple clang version 11.0.0 (clang-1100.0.33.12)
Target: x86_64-apple-darwin18.7.0
Thread model: posix
InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin

╰─$ pip install ./python_example

Processing ./python_example
Requirement already satisfied: pybind11>=2.4 in /Users/guyarad/.pyenv/versions/3.8.0/lib/python3.8/site-packages (from python-example==0.0.1) (2.4.3)
Building wheels for collected packages: python-example
  Building wheel for python-example (setup.py) ... error
  ERROR: Command errored out with exit status 1:
   command: /Users/guyarad/.pyenv/versions/3.8.0/bin/python3.8 -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/private/var/folders/gn/h71xdt2s77qd8yx32bp9hhr80000gn/T/pip-req-build-0pg446vd/setup.py'"'"'; __file__='"'"'/private/var/folders/gn/h71xdt2s77qd8yx32bp9hhr80000gn/T/pip-req-build-0pg446vd/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' bdist_wheel -d /private/var/folders/gn/h71xdt2s77qd8yx32bp9hhr80000gn/T/pip-wheel-f3cb3qjg --python-tag cp38
       cwd: /private/var/folders/gn/h71xdt2s77qd8yx32bp9hhr80000gn/T/pip-req-build-0pg446vd/
  Complete output (38 lines):
  running bdist_wheel
  running build
  running build_ext
  creating var
  creating var/folders
  creating var/folders/gn
  creating var/folders/gn/h71xdt2s77qd8yx32bp9hhr80000gn
  creating var/folders/gn/h71xdt2s77qd8yx32bp9hhr80000gn/T
  clang -Wno-unused-result -Wsign-compare -Wunreachable-code -DNDEBUG -g -fwrapv -O3 -Wall -I/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include -I/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include -I/Users/guyarad/.pyenv/versions/3.8.0/include/python3.8 -c /var/folders/gn/h71xdt2s77qd8yx32bp9hhr80000gn/T/tmpm_vh2ear.cpp -o var/folders/gn/h71xdt2s77qd8yx32bp9hhr80000gn/T/tmpm_vh2ear.o -std=c++17
  clang -Wno-unused-result -Wsign-compare -Wunreachable-code -DNDEBUG -g -fwrapv -O3 -Wall -I/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include -I/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include -I/Users/guyarad/.pyenv/versions/3.8.0/include/python3.8 -c /var/folders/gn/h71xdt2s77qd8yx32bp9hhr80000gn/T/tmpk1ewzi28.cpp -o var/folders/gn/h71xdt2s77qd8yx32bp9hhr80000gn/T/tmpk1ewzi28.o -fvisibility=hidden
  building 'python_example' extension
  creating build
  creating build/temp.macosx-10.14-x86_64-3.8
  creating build/temp.macosx-10.14-x86_64-3.8/src
  clang -Wno-unused-result -Wsign-compare -Wunreachable-code -DNDEBUG -g -fwrapv -O3 -Wall -I/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include -I/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include -I/Users/guyarad/.pyenv/versions/3.8.0/include/python3.8 -I/Users/guyarad/.local/include/python3.8 -I/Users/guyarad/.pyenv/versions/3.8.0/include/python3.8 -c src/main.cpp -o build/temp.macosx-10.14-x86_64-3.8/src/main.o -stdlib=libc++ -mmacosx-version-min=10.7 -DVERSION_INFO="0.0.1" -std=c++17 -fvisibility=hidden
  In file included from src/main.cpp:1:
  In file included from /Users/guyarad/.pyenv/versions/3.8.0/include/python3.8/pybind11/pybind11.h:44:
  In file included from /Users/guyarad/.pyenv/versions/3.8.0/include/python3.8/pybind11/attr.h:13:
  /Users/guyarad/.pyenv/versions/3.8.0/include/python3.8/pybind11/cast.h:579:34: error: aligned allocation function of type 'void *(std::size_t, std::align_val_t)' is only available on macOS 10.14 or newer
                          vptr = ::operator new(type->type_size,
                                   ^
  /Users/guyarad/.pyenv/versions/3.8.0/include/python3.8/pybind11/cast.h:579:34: note: if you supply your own aligned allocation functions, use -faligned-allocation to silence this diagnostic
  In file included from src/main.cpp:1:
  /Users/guyarad/.pyenv/versions/3.8.0/include/python3.8/pybind11/pybind11.h:1008:11: error: 'operator delete' is unavailable: introduced in macOS 10.12
          ::operator delete(p, s, std::align_val_t(a));
            ^
  /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/new:194:74: note: 'operator delete' has been explicitly marked unavailable here
  _LIBCPP_OVERRIDABLE_FUNC_VIS _LIBCPP_AVAILABILITY_SIZED_NEW_DELETE void  operator delete(void* __p, std::size_t __sz, std::align_val_t) _NOEXCEPT;
                                                                           ^
  In file included from src/main.cpp:1:
  /Users/guyarad/.pyenv/versions/3.8.0/include/python3.8/pybind11/pybind11.h:1010:11: error: 'operator delete' is unavailable: introduced in macOS 10.12
          ::operator delete(p, s);
            ^
  /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/new:177:74: note: 'operator delete' has been explicitly marked unavailable here
  _LIBCPP_OVERRIDABLE_FUNC_VIS _LIBCPP_AVAILABILITY_SIZED_NEW_DELETE void  operator delete(void* __p, std::size_t __sz) _NOEXCEPT;
                                                                           ^
  3 errors generated.
  error: command 'clang' failed with exit status 1
  ----------------------------------------
  ERROR: Failed building wheel for python-example
  Running setup.py clean for python-example
Failed to build python-example

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions