Build on macOS Catalina

Hi all.

I’ve built and installed llvm+clang from git repository on macOS Catalina. My problem now is that I get the following error building my cpp file:

clang++ -std=c++17 testcpp.cpp -o test
In file included from testcpp.cpp:1:
In file included from /usr/local/clang_llvm/bin/…/include/c++/v1/iostream:37:
In file included from /usr/local/clang_llvm/bin/…/include/c++/v1/ios:214:
In file included from /usr/local/clang_llvm/bin/…/include/c++/v1/iosfwd:95:
/usr/local/clang_llvm/bin/…/include/c++/v1/wchar.h:118:15: fatal error: ‘wchar.h’ file not found
#include_next <wchar.h>
^~~~~~~~~
1 error generated.

I get this error only on macOS and not on Linux. I’ve followed the same procedure on Linux and MacOS

On macOS I’ve created the links:

ln -s /usr/local/clang_llvm/include/c++ /usr/local/include/c++

but this doesn’t solve the problem. Any idea?

Best regards

Luca Ciciriello

Hi Luca,

You need C and C++ library headers.

C headers come as part of macOS SDK. To let compiler know about its location you need to add -DDEFAULT_SYSROOT=xcrun --show-sdk-path to CMake configuration.

C++ headers come from the toolchain. I.e. they are part of clang distribution, so you can either link to existing clang location or build libc++ to your clang build (I think this is better option): -DLLVM_ENABLE_PROJECTS=libcxx;libcxxabi

Dmitry.