macOS 'wchar.h' File Not Found

2019-01-13 10:23发布

问题:

Under OS X 10.9.5 using XCode 6.0.1 I am running into the following issue when I try to run make from the terminal:

fatal error: 'wchar.h' file not found

This issue was not happening prior to a recent upgrade to Mavericks.

回答1:

First ensure that the latest XCode is installed. Next, we need to install/fix/update Command Line Tools. To do so, run

xcode-select --install

Previously, XCode expected it's active developer directory to be located at

/Applications/Xcode.app/Contents/Developer/

but the latest Command Line Tools is installed to

/Library/Developer/CommandLineTools/

so we need to switch where XCode is looking. To do so, run

sudo xcode-select --switch /Library/Developer/CommandLineTools/

And that should be it. These steps solved the issue for myself and two coworkers.



回答2:

Adding on ssell's post and peter70's comment, I also still had issues after installing xcode command line tools again, and switching the xcode active developer directory. I was using CMake, and so deleted the debug/release folders which had existing Makefiles referencing out-of-date locations on Mojave. So for future problem resolving, after running the commands from ssell's post:

xcode-select --install

sudo xcode-select --switch /Library/Developer/CommandLineTools/

I believe if you've installed the command line tools by installing Xcode itself, you may also need to agree to the licence with sudo xcodebuild --license. I don't think this is necessary if you used the prior xcode-select command.

Then also delete generated build scripts. If using CMake, delete the cmake-build-debug and cmake-build-release directories (your names may vary)



回答3:

Make sure, you update all symbols files which have references to the wchar after updating xcode. For me full cleaning build directory has worked