'wchar.h' file not found
'wchar.h' file not found
I know about this question: macOS 'wchar.h' File Not Found
but it did not help me. I've tried reinstalling xcode, reinstalling command line tools, restarting the system. wchar.h file is in place, but the compiler does not manage to find it. What else could I try? Maybe it is sysroot related? Any way to fix that?
macbooks-MacBook-Pro:Rack euphorbium$ sudo make
c++ -Iinclude -Idep/include -Idep/lib/libzip/include -DVERSION=dev -MMD -O3 -march=core2 -ffast-math -g -Wall -DARCH_MAC -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.7.sdk -mmacosx-version-min=10.7 -DAPPLE -stdlib=libc++ -std=c++11 -stdlib=libc++ -c -o build/src/app.cpp.o src/app.cpp
clang: warning: no such sysroot directory: '/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.7.sdk' [-Wmissing-sysroot]
In file included from src/app.cpp:1:
In file included from include/app.hpp:2:
In file included from /Library/Developer/CommandLineTools/usr/include/c++/v1/vector:265:
In file included from /Library/Developer/CommandLineTools/usr/include/c++/v1/iosfwd:90:
/Library/Developer/CommandLineTools/usr/include/c++/v1/wchar.h:119:15: fatal error:
'wchar.h' file not found
#include_next <wchar.h>
^~~~~~~~~
1 error generated.
make: *** [build/src/app.cpp.o] Error 1
since wchar.h exists both in the xcode app, and in the /Library/Developer/CommandLineTools
I think that it looks for it in some completely unrelated folder.
/Library/Developer/CommandLineTools
I have no idea how to change it.
– Euphorbium
Sep 21 '17 at 12:32
I would look into the Makefile.
– user2672107
Sep 21 '17 at 12:33
4 Answers
4
I've got the same problem. I was able to fix it by using a symbolic link.
This is what I made :
cd /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/
sudo ln -s MacOSX.sdk MacOSX10.07.sdk
Then enter your root password.
NB: you have to adapt the last line with required sdk.
for macOS sierra use: sudo ln -s MacOSX.sdk MacOSX10.12sdk
– Fady Nabil Samy
Oct 2 '17 at 18:33
Delete the CMake cache as described in the Kemyar's answer!
– ante
Nov 1 '18 at 15:50
I had the same problem after upgrading to macOS High Sierra. A project which was compiling before stopped working with this error. In my case, the project files had been generated by the CMake application. The solution was to run CMake, 'Delete Cache', and 'Configure' the project again. This corrected the sysroot directory reference in the make files to point to the new SDK and the error was resolved.
Thank you! I deleted caches file and this saved a day.
– DaddyM
Nov 14 '17 at 23:51
awesome, thanks!
– Johan
Jan 16 '18 at 18:01
It was caused by incorrect sysroot, (set for an older mac os version) set in makefiles.
Thank you! I deleted caches file and this saved a day.
– DaddyM
Nov 14 '17 at 23:51
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.
/Library/Developer/CommandLineTools/Packages/macOS_SDK_headers_for_macOS_10.14.pkg
/Library/Developer/CommandLineTools/usr/include/c++/v1
/usr/local/Cellar/gcc/8.2.0/include/c++/8.2.0
The trick worked, since now the missing file "wchar.h" is right where it should be... Your settings is probably not the same, however, I am afraid.
Thanks for contributing an answer to Stack Overflow!
But avoid …
To learn more, see our tips on writing great answers.
Required, but never shown
Required, but never shown
By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.
warning: no such sysroot directory you are setting a wrong sysroot.
– user2672107
Sep 21 '17 at 12:31