I installed the C/C++ Extension for Visual Studio Code (ms-vscode.cpptools) and I'm trying to compile a .cpp file, but I keep getting fatal error C1034: iostream: no include path set.
Here is the contents of 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
}
}
]
}
Here is the contents of 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
}
and here is the exact output:
> Executing task: cl.exe /Zi /EHsc /Fe: c:\Users\User\Documents\C\cpp_workshop-cpp_ex2\main.exe c:\Users\User\Documents\C\cpp_workshop-cpp_ex2\main.cpp <
Microsoft (R) C/C++ Optimizing Compiler Version 19.00.24213.1 for x86 Copyright (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
Help me, Stack Overflow. You're my only hope!
I had same Problem which solved as Ted Lyngmo says :
open vscode with developer command prompt.
Edit :
When i open vscode with Developer Command Prompt(DCP) it don't gives such an error.
To open DCP follow steps below :
1- Open start menu(WIN key) and start typing "Developer Command Prompt" it should appear there.
2- After opening it write code . and run it. This way you opened vs code from DCP.
3- Navigate desired folder inside vscode and create cpp files there.
4- After you write your "Helloworld.cpp" press CTRL + SHIFT + B, this will compile your code
i hope this helps
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With