7

Unsurprisingly the new update of OSX Mojave broke my llvm installation in Homebrew, these are the steps I tried:

xcode-select --install # Complained, so I installed commandLineTools from here https://developer.apple.com/download/more/
xcode-select -p /Library/Developer/CommandLineTools
xcode-select --install # Now says installed
sudo xcodebuild -license # Fails, as it says I only have CommandLineTools installed in /Library/Developer/CommandLineTools not xcode

# Try something else (all versions)
brew uninstall --force llvm
brew install llvm # yay v7 how exciting

# Only it still don't work
clang++ -std=c++17 foo.cpp -o f
In file included from foo.cpp:1:
In file included from /usr/local/Cellar/llvm/7.0.0/include/c++/v1/iostream:38:
In file included from /usr/local/Cellar/llvm/7.0.0/include/c++/v1/ios:215:
In file included from /usr/local/Cellar/llvm/7.0.0/include/c++/v1/iosfwd:90:
/usr/local/Cellar/llvm/7.0.0/include/c++/v1/wchar.h:119:15: fatal error: 'wchar.h' file not found
#include_next <wchar.h>
              ^~~~~~~~~
1 error generated.

Any ideas? The first half of the things I tried I found online but mostly for older updates of MacOS, maybe Mojave broke things in a new and unpredictable way.

rausted
  • 951
  • 5
  • 21

3 Answers3

3

Here's how I solved it (very dirty but has worked for a long time):

  1. Disabled SIP on my Mac
  2. Symlinked /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include to /usr/include as is expected in POSIX environments.
  3. Re-enabled SIP.

Now I got to make a note to re-do this everytime a new OSX update comes out. This has not broken anything wrt Xcode, clang (from brew) etc so I'll keep it. Be advised though, this might break your stuff.

rausted
  • 951
  • 5
  • 21
  • This worked for me but I really don't like it. I have to reboot in recovery mode and run a script every time I update now. Recovery mode is really unpleasant. Three finger drag is disabled. The mouse sensitivity is slightly lower. Key repeat is disabled. Many command-line tools don't seem to be in my PATH so I had to use an absolute path to access micro (successor to nano). – Indiana Kernick May 05 '19 at 01:52
1

This is a well known issue of the latest macos. Try to set this environment variable, it must fix this issue.

export LIBCLANG_SYSTEM_INCLUDE_DIR="/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include"
273K
  • 29,503
  • 10
  • 41
  • 64
  • 1
    Well known where? Because I’ve been looking for a solution since yesterday. Also why downvotes it’s not intuitive at all! – rausted Nov 01 '18 at 15:59
  • 2
    I got this solution from my college. Our company forbids upgrading macos till Mojave due to having SDK and clang issues on this macos. – 273K Nov 01 '18 at 16:49
  • 2
    I see, also unfortunately that did not work for me I'm still gettting the same error despite putting the envvar in my bash_profile. – rausted Nov 01 '18 at 19:07
0

I did something dumb but it did fix the problem... Not sure if it will work for your computer though.

Here is what I did: I originally installed c++ using Homebrew on my MacBook on Mojave... so I had to manually install the Xcode CommandLineTools using the installer found at /Library/Developer/CommandLineTools/Packages/macOS_SDK_headers_for_macOS_10.14.pkg . Then I copied the "c++" folder contents from to folder /Library/Developer/CommandLineTools/usr/include/c++/v1 to the folder where I want the missing file to be, at /usr/local/Cellar/gcc/8.2.0/include/c++/8.2.0 , while replacing files with the same names.

The trick worked, since now the missing file "wchar.h" is right where it should be... I could have simlinked, in hindsight. Cheers!

Kris Stern
  • 1,192
  • 1
  • 15
  • 23