Catalina C++: Using headers yield error: no member named ‘signbit’ in the global namespace

I’m curious: What compiler are you using? What’s the value of CMAKE_OSX_SYSROOT?

I’m fairly convinced this is the result of a wrong CMAKE_OSX_SYSROOT. I had the problem you’re describing when using python bindings for clang (where CMake doesn’t manage the compiler call), but I managed to recreate the error in CMake by doing:

set(CMAKE_OSX_SYSROOT "")  # Reset.

I solved my problem by following the answers to this question: Cannot compile R packages with c++ code after updating to macOS Catalina.

To summarise: On Catalina, /usr/include is purged and protected by SIP. Thus, any project that expects the C headers to be found there will fail to compile. If I remember correctly, Apple recommends to file bug reports to projects that expect C headers in /usr/include.

You must point the build system of the code you’re trying to compile to the right headers:

(1) Make sure Xcode is up to date. There’s no telling what an outdated Xcode on Catalina might do to your build environment.

(2) Use the -isysroot /sdk/path compiler flag, where /sdk/path is the result of xcrun --show-sdk-path. I’m not sure what CMake’s best practice is, but try doing

set(CMAKE_OSX_SYSROOT /sdk/path)

or

set(CMAKE_CXX_FLAGS "[...] -isysroot /sdk/path")

If that solves the problem, you may want to look for a better way to do this in CMake.

Of course, if you’re adventurous, you could also disable SIP, as suggested in the answer to my question: /usr/include missing on macOS Catalina (with Xcode 11)

Leave a Comment