macOS 'wchar.h' File Not Found
Solution 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.
Solution 2
- My error was similar to yours which said string.h not found, I solved it by running this command:
open /Library/Developer/CommandLineTools/Packages/macOS_SDK_headers_for_macOS_10.14.pkg
I think that the problem is that for macOS Mojave users, the headers are no longer installed under /usr/include by default.
Solution 3
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)
Solution 4
Deleting all the generated files and restarted the compilation worked for me. It was suggested in this link:
https://discourse.brew.sh/t/solved-scan-build-from-llvm-7-0-seems-broken-on-macos-mojave/3151/14
Solution 5
Deleting all the generated files, like @Alfredo Morales Pinzón. If you use cmake, so you need to delete the work dictionary which is "cmake-build-debug" and regenerated the "cmake-build-debug".
ssell
C++ programmer with particular interest in Graphics and Engine development.
Updated on July 05, 2022Comments
-
ssell almost 2 years
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.
-
Euphorbium over 6 yearsDoes not work for me. I can see that wchar.h file is located on /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/wchar.h and it should be found. There is no such file in command line tools folder (and deeper there)
-
peter70 almost 6 yearsI had the same problem, but with string.h The solution for me was to delete "by hand" (with Finder) all output directories. The problem was that some old output files referenced out-of-date XCode paths. After I deleted all the output files, the problem was solved
-
Piotr99 over 5 years@peter70 Where are the output files you're referring to located? I encountered this issue with a Qt build, and I have no idea where to start looking for those output files.
-
peter70 over 5 years@Piotr99 If I remember correctly, they were the normal output files, in the output directory I specified (in Qt Projects Build Settings)
-
Jan Moritz almost 5 yearsThis works in combination with this answer stackoverflow.com/a/26185979/2652054
-
ch271828n over 3 yearsWorks for me! (Here is my case: seems that I firstly let cmake generated those files (months ago), then update the mac version, then try to make / cmake again.)
-
ch271828n over 3 yearsWorks for me! (Here is my case: seems that I firstly let cmake generated those files (months ago), then update the mac version, then try to make / cmake again.)
-
Wenmin Wu over 3 yearsNo Packages folder under /Library/Developer/CommandLineTools/.only have following folders
Library
,SDKs
andusr