3

I am getting the following error when I try to execute c++ code

In file included from /usr/local/Cellar/gcc/10.2.0_3/include/c++/10.2.0/bits/postypes.h:40,
                 from /usr/local/Cellar/gcc/10.2.0_3/include/c++/10.2.0/iosfwd:40,
                 from /usr/local/Cellar/gcc/10.2.0_3/include/c++/10.2.0/ios:38,
                 from /usr/local/Cellar/gcc/10.2.0_3/include/c++/10.2.0/ostream:38,
                 from /usr/local/Cellar/gcc/10.2.0_3/include/c++/10.2.0/iostream:39,
                 from main.cpp:1:
/usr/local/Cellar/gcc/10.2.0_3/include/c++/10.2.0/cwchar:44:10: fatal error: wchar.h: No such file or directory
   44 | #include <wchar.h>
      |          ^~~~~~~~~
compilation terminated.

I am using gcc10 on MacOS Big Sur 11.2 The compiler was working fine till I updated homebrew or updated to Big Sur 11.2. Running brew cleanup could've also broken it. I have tried unlinking and linking gcc again but that had no effect. What can I do to fix this error? Would it be better to delete and reinstall gcc?

  • You didn't specified stdlib for gcc. Bet they changed default locations for shared libs gcc wanted to resolve to. Something like stdlib. [check this](https://stackoverflow.com/questions/19774778/when-is-it-necessary-to-use-the-flag-stdlib-libstdc) – Sugar Feb 11 '21 at 17:09
  • No, you're getting that error when you're *compiling* C++ code. Please update your question to show the exact compilation command you used. – Keith Thompson Feb 11 '21 at 18:29

1 Answers1

0

This issue got fixed by updating my xcode command line tools