*更新:
关于类似问题macos-wchar-h-file-not-found,命令行工具switch(xcode-select --install)不再存在。
我正在运行macOS Monterey系统,并尝试使用g++-11命令(我使用homebrew安装了gcc)编译一个简单的hello world .cpp文件,但是出现以下错误:
我正在运行macOS Monterey系统,并尝试使用g++-11命令(我使用homebrew安装了gcc)编译一个简单的hello world .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;
}
-I /Library/Developer/CommandLineTools/SDKs/MacOSX10.15.sdk
。 - Richard BarberCellar/gcc/11.2.0_3/include/c++/11/tr1
中有wchar.h
。如果没有,你可以尝试重新安装或检查gcc的包含路径。 - halfelf