Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Visual Studio Code-Cannot open source file "iostream"

I just want to try c++ coding with Visual Studio code. I have installed vscode 1.18.1 to my laptop (Win10-64).

I got errors by typing following code:

#include <iostream>
using namespace std;
int main()
{
    std::cout << "Hello world!" <<endl;
    return 0;
}

Should happen no Error. C:\Users\Harri\OneDrive\Tiedostot\Demo2.vscode\c_cpp_properties.json -content:

"path": [ "/usr/include", "/usr/local/include", "${workspaceRoot}" ],

Problems/Errors for row 1:

" #include errors detected. Please update your includePath. IntelliSense features for this translation unit (C:\Users\Harri\OneDrive\Tiedostot\Demo2\Calc.cpp) will be provided by the Tag Parser. "

" cannot open source file "iostream" "

like image 612
Mr72 Avatar asked Apr 11 '26 20:04

Mr72


1 Answers

I had the same problem, but it was easily solved by setting the "Compiler path" in the C/C++ configurations. VS Code then found the library directly and compiled the project.

Screenshot from settings screen in VS Code

like image 96
Sven Arno Jopen Avatar answered Apr 13 '26 11:04

Sven Arno Jopen