*Update: Regarding the similar question macos-wchar-h-file-not-found, the command line tool switch(xcode-select --install) doesn't exist anymore.
I am running on macOS Monterey system and I am trying to compile a simple hello world .cpp file using the g++-11 commend (I installed gcc using homebrew), I am getting the following error:
/usr/local/Cellar/gcc/11.2.0_3/include/c++/11/cwchar:44:10: fatal error: wchar.h: No such file or directory
44 | #include <wchar.h>
| ^~~~~~~~~
I tried two compile commands:
g++-11 -c hello.cpp -o hell.o
g++-11 -std=c++11 -c hello.cpp -o hell.o
Here is the file I am trying to compile:
//
// main.cpp
// Test
//
// Created by Jiali Zhu on 1/9/22.
//
#include <iostream>
int main(int argc, const char * argv[]) {
// insert code here...
std::cout << "Hello, World!\n";
return 0;
}