3

I am trying to compile a Cpp program with g++ compiler, but I am getting this error:

Yuliam-MBP:Documents yuliamosh$ g++-9 -std=c++17 -Wall -Wextra -pedantic vector.cpp -o vector
In file included from /usr/local/Cellar/gcc/9.2.0_3/include/c++/9.2.0/bits/postypes.h:40,
                 from /usr/local/Cellar/gcc/9.2.0_3/include/c++/9.2.0/iosfwd:40,
                 from /usr/local/Cellar/gcc/9.2.0_3/include/c++/9.2.0/ios:38,
                 from /usr/local/Cellar/gcc/9.2.0_3/include/c++/9.2.0/ostream:3,
                 from /usr/local/Cellar/gcc/9.2.0_3/include/c++/9.2.0/iostream:39,
                 from vector.cpp:1:
/usr/local/Cellar/gcc/9.2.0_3/include/c++/9.2.0/cwchar:44:10: fatal error: wchar.h: No such file or directory
   44 | #include <wchar.h>
      |          ^~~~~~~~~
compilation terminated.
Parth
  • 2,682
  • 1
  • 20
  • 39
YuliaM95
  • 35
  • 6

2 Answers2

0

It seems like "wchar.h" was not found.

I would suggest to follow the instructions from this thread.

HWilmer
  • 458
  • 5
  • 14
  • I am getting error for both wchar.h and also for stdlib.h. – YuliaM95 Feb 08 '20 at 19:50
  • have you tried the suggestions from the comments in that thread. That seems to be your exact problem. Also I would compile with clang on MacOs – HWilmer Feb 08 '20 at 19:53
  • I had already tried things related to that thread as well. nothing seems working. I deleted old object files and complied again. Tried installing packages as well. And also I ran all the commands suggested there as well. – YuliaM95 Feb 08 '20 at 19:55
0

INSTALL
xcode-select --install

THEN SWITCH TO NEWLY INSTALLED TOOLS
sudo xcode-select --switch /Library/Developer/CommandLineTools/

You might need to reset the default location of the compile tools:

xcode-select --reset

These are the usual fixes. SADLY, NONE OF THEM WORKED FOR ME!

THIS IS WHAT WORKED FOR ME: Homebrew Solution

PhillipJacobs
  • 2,337
  • 1
  • 16
  • 32
  • what exactly you did to fix the problem?? Below mentioned one? if so I am unable to follow the steps can you please elaborate it please. "-isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk to CPPFLAGS..."?? – YuliaM95 Feb 09 '20 at 10:41
  • Does anyone have any idea how to solve this issue? need help, please. – YuliaM95 Feb 09 '20 at 12:49
  • I literally posted the link that worked for me lol. Check it out! – PhillipJacobs Jan 29 '23 at 05:49