c++ - 无法在 vscode MacOS Catalina 中编译 C++ 代码
问题描述
我正在尝试在 Mac 上使用 vscode 编写 c++,但是在尝试运行任何代码时我一直收到此错误。
我要运行的代码:
#include <iostream>
int main() {
std::cout << "Hello World!";
return 0;
}
我得到的错误:
[Running] cd "/Users/joanne/Desktop/C++/" && g++ Hello.cpp -o Hello && "/Users/joanne/Desktop/C++/"Hello
In file included from /Users/joanne/anaconda3/gcc/include/c++/cwchar:44:0,
from /Users/joanne/anaconda3/gcc/include/c++/bits/postypes.h:40,
from /Users/joanne/anaconda3/gcc/include/c++/iosfwd:40,
from /Users/joanne/anaconda3/gcc/include/c++/ios:38,
from /Users/joanne/anaconda3/gcc/include/c++/ostream:38,
from Hello.cpp:1:
/Users/joanne/anaconda3/gcc/include/c++/wchar.h:29:24: fatal error: wchar.h: No such file or directory
#include_next "wchar.h"
^
compilation terminated.
[Done] exited with code=1 in 0.096 seconds
一些信息:
macOS Catalina 10.15.2
Xcode 10.4.1
$ clang --version
clang version 4.0.1 (tags/RELEASE_401/final)
Target: x86_64-apple-darwin19.2.0
Thread model: posix
InstalledDir: /Users/joanne/anaconda3/bin
$ gcc --version
gcc (GCC) 4.8.5
Copyright (C) 2015 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
$ which gcc
/Users/joanne/anaconda3/bin/gcc
$ /usr/bin/gcc --version
Configured with: --prefix=/Library/Developer/CommandLineTools/usr --with-gxx-include-dir=/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/4.2.1
Apple clang version 11.0.3 (clang-1103.0.32.59)
Target: x86_64-apple-darwin19.2.0
Thread model: posix
InstalledDir: /Library/Developer/CommandLineTools/usr/bin
我也安装/usr/local/Cellar/gcc/9.3.0_1/bin
了自制软件。
我的包含路径设置:
{
"configurations": [
{
"name": "Mac",
"includePath": [
"${workspaceFolder}/**",
"/Library/Developer/CommandLineTools/SDKs/MacOSX10.15.sdk/usr/include/c++",
"/usr/local/Cellar/gcc/9.3.0_1/include/",
"/Library/Developer/CommandLineTools/usr/include/c++",
"/Users/joanne/anaconda3/gcc/include/c++",
"/Library/Developer/CommandLineTools/usr/include/c++/v1",
"/usr/local/Cellar/gcc/9.3.0_1/include/c++/9.3.0/x86_64-apple-darwin19",
"/Users/joanne/anaconda3/gcc/include/c++/x86_64-apple-darwin11.4.2"
],
"defines": [],
"macFrameworkPath": [
"/System/Library/Frameworks",
"/Library/Developer/CommandLineTools/SDKs/MacOSX10.15.sdk/Library/Apple/System/Library/Frameworks",
"/Library/Frameworks"
],
"compilerPath": "/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang",
"cStandard": "c11",
"cppStandard": "c++17",
"intelliSenseMode": "clang-x64"
}
],
"version": 4
}
我试过open macOS_SDK_headers_for_macOS_10.14.pkg
但它不起作用,因为macOS_SDK_headers_for_macOS_10.14.pkg
我猜 macOS Catalina 中没有命名文件了?
有人知道怎么修这个东西吗?
解决方案
推荐阅读
- java - 多态性最佳实践
- c# - C# 中的全局静态字典
- java - spring mvc中的错误404但适用于其他人
- git - 提交和推送快进合并时,BitBucket 挂钩不会删除 PR 的批准
- python - 如何将列表中的嵌套字典放入Dataframe?
- extjs - 使用 selectionModel 获取网格内的复选框值
- php - FOSUserBundle 中的 EmailConfirmationListener 未重定向到 fos_user_registration_check_email
- outlook - Outlook for Mac 允许 AppDomain 之外的域
- php - 选择数组内(另一个数组内)包含相同值的所有键
- linear-algebra - 在 AB = C 中求解矩形 A