Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

'wchar.h' file not found

Tags:

c++

xcode

ios

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.

like image 889
Euphorbium Avatar asked Sep 21 '17 11:09

Euphorbium


3 Answers

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.

like image 129
alain Avatar answered Nov 11 '22 07:11

alain


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.

like image 16
Kamyar Avatar answered Nov 11 '22 07:11

Kamyar


For any one struggling with this on MacOSX Mojave this answer solves it. In short:

  • Go to the terminal and run open /Library/Developer/CommandLineTools/Packages/macOS_SDK_headers_for_macOS_10.14.pkg This will bring up the prompt to install Xcode tools.
  • After that's done got to the terminal and run sudo xcode-select -s /Library/Developer/CommandLineTools
like image 9
ssh Avatar answered Nov 11 '22 07:11

ssh