*更新:对于类似的问题macos-wchar-h-file-not-found,命令行工具开关(xcode-select-install)不再存在。
我运行在macOS蒙特利系统上,我试图使用g++-11推荐(我用自制安装gcc )编译一个简单的hello .cpp文件,我得到了以下错误:
/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>
| ^~~~~~~~~我尝试了两个编译命令:
g++-11 -c hello.cpp -o hell.o
g++-11 -std=c++11 -c hello.cpp -o hell.o下面是我要编译的文件:
//
// 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;
}发布于 2022-01-17 14:24:38
我也有同样的问题,在我的例子中,这个问题是过时的命令行开发工具。
我是从跑步中发现的
$ brew doctor
...
Warning: Your Command Line Tools are too outdated.
Update them from Software Update in System Preferences or run:
softwareupdate --all --install --force
If that doesn't show you any updates, run:
sudo rm -rf /Library/Developer/CommandLineTools
sudo xcode-select --install
Alternatively, manually download them from:
https://developer.apple.com/download/all/.
You should download the Command Line Tools for Xcode 13.1.我试图通过softwareupdate -l更新它们,但是这并没有给我任何更新信息。
因此,删除了它们并重新安装了xcode-select --install。
在这之后,g++-11停止给我一个关于这个标题的错误。
现在brew config告诉我我有CLT: 13.0.0.0.1.1627064638
附注:
另外,我启动了xcode,它问我是否需要安装其他组件,我说是的。
https://stackoverflow.com/questions/70660993
复制相似问题