/usr/local/Cellar/gcc/10.2.0/include/c++/10.2.0/cwchar:44:10: 致命错误:wchar.h: 没有这样的文件或目录自制 GCC 编译器不工作

问题描述

我已经使用“brew install gcc”命令通过 Homebrew 在我的 Mac 上安装了 GCC 编译器。安装成功,但是当我尝试编译一个简单的 C++ 程序时,我遇到了错误

#include <iostream>
#include <bits/stdc++.h>

using namespace std;

int main(){
    cout<<"Hello Mac"<<endl;
    return 0;
}

错误信息

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.

我已经尝试过的东西

  1. 使用较早的版本(gcc 版本 -6.5.0)进行编译,我最终遇到了同样的错误
  2. 使用 gcc-10 命令编译 C 文件 -> 它抛出类似的类型 (没有这样的文件错误
  3. 更新 Xcode 命令行工具和 Home brew。

我使用的是运行 macOS Big Sur 的 M1 MacBook Air 2020。

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)