gpt4 book ai didi

c++ - Visual Studio Code C/C++ 扩展没有为编译器设置包含路径

转载 作者:行者123 更新时间:2023-12-05 03:51:35 33 4
gpt4 key购买 nike

我安装了 Visual Studio Code 的 C/C++ 扩展 (ms-vscode.cpptools),我正在尝试编译一个 .cpp 文件,但我不断收到 fatal error C1034 : iostream: 没有包含路径集

这里是 tasks.json 的内容:

{
"version": "2.0.0",
"tasks": [
{
"type": "shell",
"label": "C/C++: cl.exe build active file",
"command": "cl.exe",
"args": [
"/Zi",
"/EHsc",
"/Fe:",
"${fileDirname}\\${fileBasenameNoExtension}.exe",
"${file}"
],
"options": {
"cwd": "${workspaceFolder}"
},
"problemMatcher": [
"$msCompile"
],
"group": {
"kind": "build",
"isDefault": true
}
}
]
}

c_cpp_properties.json 的内容如下:

{
"configurations": [
{
"name": "Win32",
"defines": [
"_DEBUG",
"UNICODE",
"_UNICODE"
],
"windowsSdkVersion": "8.1",
"compilerPath": "C:/Program Files (x86)/Microsoft Visual Studio/2019/Community/VC/Tools/MSVC/14.26.28801/bin/Hostx64/x64/cl.exe",
"cStandard": "c11",
"cppStandard": "c++17",
"intelliSenseMode": "msvc-x64"
}
],
"version": 4
}

这是准确的输出:

> Executing task: cl.exe /Zi /EHsc /Fe: c:\Users\User\Documents\C\cpp_workshop-cpp_ex2\main.exec:\Users\User\Documents\C\cpp_workshop-cpp_ex2\main.cpp <

Microsoft (R) C/C++ Optimizing Compiler Version 19.00.24213.1 for x86Copyright (C) Microsoft Corporation. All rights reserved.

main.cpp

c:\Users\User\Documents\C\cpp_workshop-cpp_ex2\main.cpp(21):fatal error C1034: iostream: no include path set

The terminal process terminated with exit code: 1

帮助我,Stack Overflow。你是我唯一的希望!

最佳答案

我有同样的问题解决了 Ted Lyngmo说:

使用开发人员命令提示符打开 vscode。

编辑:
当我使用 Developer Command Prompt(DCP) 打开 vscode 时,它​​不会给出这样的错误。
要打开 DCP,请按照以下步骤操作:
1- 打开开始菜单(WIN 键)并开始输入“开发人员命令提示符”,它应该出现在那里。
2- 打开后编写 code . 并运行它。这样你就可以从 DCP 打开 vs code。
3- 在 vscode 中导航所需的文件夹并在那里创建 cpp 文件。
4- 编写完“Helloworld.cpp”后按 CTRL + SHIFT + B,这将编译您的代码

希望对你有帮助

关于c++ - Visual Studio Code C/C++ 扩展没有为编译器设置包含路径,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62783344/

33 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com