I have installed GCC compiler on my Mac through Homebrew using "brew install gcc" command. The installation was successful, but when I try to compile a simple C++ program I run into error.
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
int main(){
cout<<"Hello Mac"<<endl;
return 0;
}
Error Message
swithinabner@Johns-Air Bench % g++-10 Bench.cpp
In file included from /usr/local/Cellar/gcc/10.2.0/include/c++/10.2.0/bits/postypes.h:40,
from /usr/local/Cellar/gcc/10.2.0/include/c++/10.2.0/iosfwd:40,
from /usr/local/Cellar/gcc/10.2.0/include/c++/10.2.0/ios:38,
from /usr/local/Cellar/gcc/10.2.0/include/c++/10.2.0/ostream:38,
from /usr/local/Cellar/gcc/10.2.0/include/c++/10.2.0/iostream:39,
from Bench.cpp:1:
/usr/local/Cellar/gcc/10.2.0/include/c++/10.2.0/cwchar:44:10: fatal error: wchar.h: No such file or directory
44 | #include <wchar.h>
| ^~~~~~~~~
compilation terminated.
WHAT I HAVE ALREADY TRIED
- Compiling using an earlier version (gcc version -6.5.0) and I end up with the same error.
- Compiling a C file using gcc-10 command -> It throws up similar kind of (No such file) error.
- Updating Xcode Command line tools and Home brew.
I'm using a M1 MacBook Air 2020 which runs macOS Big Sur.