No such file or directory #include <iostream>

107 Views Asked by At

I use Visual Studio Code, and i have a problem with the extension for the C++.

When i include iostream it returns me that error:

#include errors detected. Please update your includePath. Squiggles are disabled for this translation unit (C:\Users\****\Desktop\*****\test.cpp).C/C++(1696)

cannot open source file "iostream". Please run the 'Select IntelliSense Configuration...' command to locate your system headers.C/C++(1696)

I use msys64's ucrt64 as compiler. The most weird thing is that when i compile and execute it, it works well. It doesn't give me any errors.

This is my c_cpp_properties.json :

{
"configurations": [
    {
        "name": "Win64",
        "includePath": [
            "${workspaceFolder}/**",
            "C:\\msys64\\ucrt64\\include/**"
        ],
        "defines": [
            "_DEBUG",
            "UNICODE",
            "_UNICODE"
        ],
        "windowsSdkVersion": "10.0.22621.0",
        "cStandard": "c17",
        "cppStandard": "c++17",
        "intelliSenseMode": "${default}",
        "compilerPath": "C:/msys64/ucrt64/bin/g++.exe"
    }
],
"version": 4
}
1

There are 1 best solutions below

1
YSin On

Maybe you can go to C/C++ Configuration, try changing the compiler path to g++.exe and under the IntelliSense mode, choose ${default}. Hope it helps.

Please refer to this link: https://www.youtube.com/watch?v=LE9iJ9TpZlU