Include iostream ошибка vs code

Hello, so I am new to coding and wanted to use VS Code to code in C++, so I installed it, installed C/C++ IntelliSense v0.12.4 and followed instructions on the VS Code website to make a c_cpp_prope...

Hello, so I am new to coding and wanted to use VS Code to code in C++, so I installed it, installed C/C++ IntelliSense v0.12.4 and followed instructions on the VS Code website to make a c_cpp_properties.json file and copied the code into it like they said. When I open my .cpp project that I had made in notepad++, I get the error:
«#include errors detected. Please update your includePath. IntelliSense features for this translation unit (directoryfile.cpp) will be provided by the Tag Parser. (9, 1)
cannot open source file «iostream» (9, 1)»

My .cpp code
`#include

using namespace std;

int main()
{
string firstName, lastName;
double hourRate, numHours;

    cout << "+----------------------------------------+" << endl;
    cout << " Your first name and last name: ";
    cin >> firstName >> lastName;
    cout << " Your hourly rate: ";
    cin >> hourRate;
    cout << " Number of hours worked last week: ";
    cin >> numHours;
    cout << endl;
    
    double regPay, overTPay, gPay, socSec, med, netPay;
    if (numHours <= 40)
    {
        regPay = hourRate * numHours;
        gPay = regPay;
        overTPay = 0;
    }
        else
        {
            double oTHours;
            oTHours = numHours - 40;
            regPay = hourRate * (numHours - (numHours - 40));
            overTPay = (hourRate * 1.5) * oTHours;
            gPay = regPay + overTPay;
        }
    socSec = gPay * 0.062;
    med = gPay * 0.0145;
    netPay = gPay - (socSec + med);
    cout << "+----------------------------------------+" << endl << endl;
    cout << " Pay Stubn" << " Regular pay  $" << regPay << endl;
    cout << " Overtime pay $" << overTPay << endl;
    cout << " Gross pay    $" << gPay << endl;
    cout << " Social Sec.  $" << socSec << endl;
    cout << " Medicare     $" << med << endl;
    cout << " Net Pay      $" << netPay << endl << endl;
    cout << "+----------------------------------------+" << endl << endl;
    cout << " Pay to: " << firstName << " " << lastName << endl;
    cout << " Total Pay: $" << netPay << endl << "ttt   ";
    cout << "Signed: P inc." << endl;
    cout << "+----------------------------------------+" << endl;
    
    return 0;
}`

My c_cpp_properties.json file

{
    "configurations": [
        {
            "name": "Mac",
            "includePath": [
                "/usr/include",
                "/usr/local/include",
                "${workspaceRoot}"
            ],
            "defines": [],
            "intelliSenseMode": "clang-x64",
            "browse": {
                "path": [
                    "/usr/include",
                    "/usr/local/include",
                    "${workspaceRoot}"
                ],
                "limitSymbolsToIncludedHeaders": true,
                "databaseFilename": ""
            },
            "macFrameworkPath": [
                "/System/Library/Frameworks",
                "/Library/Frameworks"
            ]
        },
        {
            "name": "Linux",
            "includePath": [
                "/usr/include",
                "/usr/local/include",
                "${workspaceRoot}"
            ],
            "defines": [],
            "intelliSenseMode": "clang-x64",
            "browse": {
                "path": [
                    "/usr/include",
                    "/usr/local/include",
                    "${workspaceRoot}"
                ],
                "limitSymbolsToIncludedHeaders": true,
                "databaseFilename": ""
            }
        },
        {
            "name": "Win32",
            "includePath": [
                "${workspaceRoot}"
            ],
            "defines": [
                "_DEBUG",
                "UNICODE"
            ],
            "intelliSenseMode": "msvc-x64",
            "browse": {
                "path": [
                    "${workspaceRoot}",
                    "C:/MinGW/lib/gcc/mingw32/6.3.0/include/c++",
                ],
                "limitSymbolsToIncludedHeaders": true,
                "databaseFilename": ""
            }
        }
    ],
    "version": 3
}

Also, when I hover over the «» this shows up:
«#include errors detected. Please update your includePath. IntelliSense features for this translation unit (E:StuffCS11-ThingsHomeworksA3paycheck.cpp) will be provided by the Tag Parser.
cannot open source file «iostream»»

Let me know if you need any more information

In c++ project when you have included header file, but inside project we are not able to access that header file then generally we get error for cannot open source file. For fixing this error check that included file is available in project include path or not.

cannot open source file visual studio C++

Solution-1 : Check your Visual Studio Project settings under C++, Check Include directories and make sure Your_filename.h is pointing to correct path. After adding proper include directories it will resolve cannot open source file visual studio error.

visual studio additional include directory
include directories to your header file

You can right click to header file and open from visual studio. If file is pointing properly it will open.

open c++ header file
Right click and try to open header file

If your include file is not properly pointing or you have not added inside your included directory then you will not able to open from visual studio.

error while opening header file
if file is not included in project then give this error

Solution-2 : Another solution, If your header file is at different folder/location then you can include file path directly in header file. Here you can use relative path or you can provide full path of header file.

Include based on your project folder structure and requirement.

#include "../FolderName/filename.h"
OR
#include "./FolderName/filename.h"
OR
#include "FullPath/filename.h"

Solution-1: iostream file opening error normally comes when we are missing $(IncludePath) inside Properties->VC++ Directories->Include Directories. And you have by mistake removed Include path.

Solution-2: Other possible reason is that during installing Visual studio you did not selected c++ packages.

Solution-3: You can check by including stdafx.h in starting (only for Visual studio projects)

#include "stdafx.h"
#include <iostream>
using namespace std;

Solution-4: Sometimes these type of error comes when multiple Visual Studio versions are install in single PC. You can check Projects and Solutions –> VC++ Directories, are properly added for your project and pointing to correct version location.

For Visual Studio Code:

c++ cannot open source file iostream in visual studio code can also occurs when proper paths are not added inside visual studio code c_cpp_properties.json file.

Mode details:

https://code.visualstudio.com/docs/cpp/config-msvc#_prerequisites

cannot open source file “string”

Try below steps to resolve error.

1) Open VC++ Directories option inside Configuration Properties of visual studio
2) Her all directories value (e.g. Executable directories) will be available, just you need to select drop-down and click edit
3) Remove selection of Inherit from parent
4) Now just click OK and you will see no changes inside Edit box.
5) You need to repeat this thing for all directories, At the end executable directories will be set to $(ExecutablePath) and Include directories will be set to $(IncludePath), similar way to all directories
6)Now click apply and then OK

Conclusion for cannot open source file c++

We have provided solutions for multiple errors for can not open source file c++, If you try given solution hopefully you will able to resolve error. But if still you are getting error you can add your comment and code. We will try to resolve and find solution for you. Happy coding 🙂

Reader Interactions

P1XELCORE

0 / 0 / 0

Регистрация: 11.04.2013

Сообщений: 78

1

10.08.2020, 16:18. Показов 78110. Ответов 26

Метки нет (Все метки)


Всем привет, хотел начать писать на плюсах в vs code, установил, всё гуд, mingw поставил, настроил всё, когда начинаю компилировать прогу выдает ошибки «Обнаружены ошибки #include. Измените includePath», что он хочет от меня?? (os win10)

Это файл c_cpp_properties.json

JSON
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
{
    "configurations": [
        {
            "name": "Win32",
            "includePath": [
                "${workspaceFolder}/**",
                "C:\MinGW\lib\gcc\mingw32\9.2.0\include\c++"
            ],
            "defines": [
                "_DEBUG",
                "UNICODE",
                "_UNICODE"
            ],
            "compilerPath": "C:\MinGW\bin\gcc.exe",
            "cStandard": "c11",
            "cppStandard": "gnu++14",
            "intelliSenseMode": "gcc-x86",
            "browse": {
                "path": []
            }
        }
    ],
    "version": 4
}

launch.json

JSON
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
  "version": "0.2.0",
    "configurations": [
        {
            "name": "g++.exe - Сборка и отладка активного файла",
            "type": "cppdbg",
            "request": "launch",
            "program": "${fileDirname}\${fileBasenameNoExtension}.exe",
            "args": [],
            "stopAtEntry": false,
            "cwd": "${workspaceFolder}",
            "environment": [],
            "externalConsole": false,
            "MIMode": "gdb",
            "miDebuggerPath": "C:\MinGW\bin\gdb.exe",
            "setupCommands": [
                {
                    "description": "Включить автоматическое форматирование для gdb",
                    "text": "-enable-pretty-printing",
                    "ignoreFailures": true
                }
            ],
            "preLaunchTask": "C/C++: g++.exe build active file"
        }
    ]
}

tasks.json

JSON
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
{
    "version": "2.0.0",
    "tasks": [
        {
            "type": "shell",
            "label": "C/C++: g++.exe build active file",
            "command": "C:\MinGW\bin\g++.exe",
            "args": [
                "-g",
                "${file}",
                "-o",
                "${fileDirname}\${fileBasenameNoExtension}.exe"
            ],
            "options": {
                "cwd": "C:\MinGW\bin"
            },
            "problemMatcher": [
                "$gcc"
            ],
            "group": {
                "kind": "build",
                "isDefault": true
            }
        }
    ]
}

__________________
Помощь в написании контрольных, курсовых и дипломных работ, диссертаций здесь



0



Programming

Эксперт

94731 / 64177 / 26122

Регистрация: 12.04.2006

Сообщений: 116,782

10.08.2020, 16:18

26

406 / 290 / 119

Регистрация: 18.07.2017

Сообщений: 1,346

11.08.2020, 13:06

2

Цитата
Сообщение от P1XELCORE
Посмотреть сообщение

Обнаружены ошибки #include. Измените includePath», что он хочет от меня?

Тебя на шелле, чтоли читать учили, раз ты не видишь то, что после хеш-тега?
Проверь пути до директорий с исходниками и либами.

Цитата
Сообщение от P1XELCORE
Посмотреть сообщение

«includePath»: [
«${workspaceFolder}/**»,
«C:\MinGW\lib\gcc\mingw32\9.2.0\include\c++ «
],

Проверь наличие таких директорий, либо поправь пути если они в другом месте.



0



0 / 0 / 0

Регистрация: 11.04.2013

Сообщений: 78

11.08.2020, 13:15

 [ТС]

3

Цитата
Сообщение от assemberist
Посмотреть сообщение

Проверь наличие таких директорий, либо поправь пути если они в другом месте.

я сам прописал этот путь, было бы странно если бы там не было этих директорий)
изначально там не было пути, поэтому я решил что стоит в includPath ещё и путь прописать поэтому так и сделал, но это не решило моей проблемы



0



фрилансер

4479 / 3989 / 870

Регистрация: 11.10.2019

Сообщений: 10,505

11.08.2020, 13:50

4

P1XELCORE, ${workspaceFolder}/**

звёзды вроде не к месту ?

редактируй эти настройки через визард, тогда будет меньше ошибок



0



0 / 0 / 0

Регистрация: 11.04.2013

Сообщений: 78

11.08.2020, 14:12

 [ТС]

5

Цитата
Сообщение от Алексей1153
Посмотреть сообщение

звёзды вроде не к месту ?

Они по дефолту стояли в этом файле. Как я понял не просто так, т.к. про них написано в справочнике «Если путь заканчивается на /**, подсистема IntelliSense будет выполнять рекурсивный поиск файлов заголовков, начиная с этого каталога.»

Цитата
Сообщение от Алексей1153
Посмотреть сообщение

редактируй эти настройки через визард, тогда будет меньше ошибок

не совсем понимаю что значит редактировать через визард)



0



фрилансер

4479 / 3989 / 870

Регистрация: 11.10.2019

Сообщений: 10,505

11.08.2020, 14:19

6

Цитата
Сообщение от P1XELCORE
Посмотреть сообщение

через визард

то есть, напрямую файл править не надо, надо открывать свойства проекта — зависимости, пути и т.д. Там же можно посмотреть, во что раскрываются макросы вида ${…}

Добавлено через 1 минуту

Цитата
Сообщение от P1XELCORE
Посмотреть сообщение

«Обнаружены ошибки #include. Измените includePath»,

а покажи скрин, кстати



1



0 / 0 / 0

Регистрация: 11.04.2013

Сообщений: 78

11.08.2020, 14:58

 [ТС]

7

Цитата
Сообщение от Алексей1153
Посмотреть сообщение

а покажи скрин, кстати

Ошибка include, измените includePath в VS code



0



фрилансер

4479 / 3989 / 870

Регистрация: 11.10.2019

Сообщений: 10,505

11.08.2020, 15:07

8

P1XELCORE, iostream

и настройки тут ни при чём



1



0 / 0 / 0

Регистрация: 11.04.2013

Сообщений: 78

11.08.2020, 15:08

 [ТС]

9

в самом коде подчеркивает проблему именно подключение библиотеки, если выбрать «Изменить параметр includePath», то кидает на вкладку изменения конфигурации IntelliSense, там по логике прописываются пути для компилятора и библиотек

Ошибка include, измените includePath в VS code



0



0 / 0 / 0

Регистрация: 11.04.2013

Сообщений: 78

11.08.2020, 15:09

 [ТС]

10

Цитата
Сообщение от Алексей1153
Посмотреть сообщение

P1XELCORE, iostream
и настройки тут ни при чём

действительно, спасибо огромное) запустилось!

только теперь ругается консоль отладки, но всё же спасибо)



0



фрилансер

4479 / 3989 / 870

Регистрация: 11.10.2019

Сообщений: 10,505

11.08.2020, 19:31

11

Цитата
Сообщение от P1XELCORE
Посмотреть сообщение

теперь ругается консоль отладки

как ругается ?



0



0 / 0 / 0

Регистрация: 11.04.2013

Сообщений: 78

12.08.2020, 08:46

 [ТС]

12

Цитата
Сообщение от Алексей1153
Посмотреть сообщение

как ругается ?

Ошибка include, измените includePath в VS code

вот эти строки о том что какие-то символы загружены, они так и должны быть? мне кажется в окно вывода должно просто хеллоу ворд выходить)
а если например написать программу где нужно вводить входные данные, то она отладку не проходит вовсе



0



фрилансер

4479 / 3989 / 870

Регистрация: 11.10.2019

Сообщений: 10,505

12.08.2020, 09:05

13

P1XELCORE, так и смотри в окне вывода. У тебя всё там не на английском, но предполагаю, это вкладка «выходные данные»

а может и «терминал». Или вообще окно в настройках не включено

Добавлено через 3 минуты
так вон, вроде, текст то вывелся синеньким. Только всякий мусор вокруг. Да и код выхода 0 вижу



0



406 / 290 / 119

Регистрация: 18.07.2017

Сообщений: 1,346

12.08.2020, 09:41

14

Цитата
Сообщение от P1XELCORE
Посмотреть сообщение

какие-то символы загружены

Судя по всему это загрузка метаданных для дебаггера из модулей, которые будут использоваться твоей программой.

Цитата
Сообщение от P1XELCORE
Посмотреть сообщение

мне кажется в окно вывода должно просто хеллоу ворд выходить

А мне кажеся, что дебаггеру плевать на ввод-вывод, если не поставлена точка останова. Если у этой консоли та же логика что и в gdb, то туда нужно вводить название переменных либо выражения. И дебаггер покажет значение переменной, либо рассчитает выражение.

Цитата
Сообщение от P1XELCORE
Посмотреть сообщение

программу где нужно вводить входные данные, то она отладку не проходит вовсе

Всмысле не проходит? Зависает? Ну так может нужно данные вводить не в консоль отладки, а в окно самой программы? У тебя там консолька не всплывает случаем на фоне?



0



0 / 0 / 0

Регистрация: 11.04.2013

Сообщений: 78

12.08.2020, 10:21

 [ТС]

15

Цитата
Сообщение от Алексей1153
Посмотреть сообщение

но предполагаю, это вкладка «выходные данные»
а может и «терминал». Или вообще окно в настройках не включено

Во вкладке «выходные данные» пусто всегда, а в терминале вот такое выходит когда без проблем компилируется

Миниатюры

Ошибка include, измените includePath в VS code
 

Ошибка include, измените includePath в VS code
 



0



0 / 0 / 0

Регистрация: 11.04.2013

Сообщений: 78

12.08.2020, 10:25

 [ТС]

16

Цитата
Сообщение от assemberist
Посмотреть сообщение

Всмысле не проходит? Зависает? Ну так может нужно данные вводить не в консоль отладки, а в окно самой программы? У тебя там консолька не всплывает случаем на фоне?

Консолька не всплывает для ввода данных, просто опять что-то пишет в консоль отладки и в терминал

Миниатюры

Ошибка include, измените includePath в VS code
 

Ошибка include, измените includePath в VS code
 



0



Алексей1153

фрилансер

4479 / 3989 / 870

Регистрация: 11.10.2019

Сообщений: 10,505

12.08.2020, 10:46

17

P1XELCORE, кстати, да, у тебя приложение то консольное? Тогда консоль должна быть на экране. А в окно отладки, которое снизу, вывод в студии производится через TRACE/TRACE0/OutputDebugString (понадобится заголовок <Windows.h> )

Добавлено через 2 минуты
ещё, говорят, так можно показать/скрыть (тоже тот же заголовок нужен)

C++
1
2
ShowWindow (GetConsoleWindow(), SW_SHOW);
ShowWindow (GetConsoleWindow(), SW_HIDE);



0



406 / 290 / 119

Регистрация: 18.07.2017

Сообщений: 1,346

12.08.2020, 10:53

18

Цитата
Сообщение от P1XELCORE
Посмотреть сообщение

просто опять что-то пишет в консоль отладки и в терминал

Ну ок, а почему точку останова до сих пор не поставил? Как у тебя дебаггер будет стопать программу?



0



0 / 0 / 0

Регистрация: 11.04.2013

Сообщений: 78

12.08.2020, 11:06

 [ТС]

19

Цитата
Сообщение от assemberist
Посмотреть сообщение

Ну ок, а почему точку останова до сих пор не поставил? Как у тебя дебаггер будет стопать программу?

Поставил) всё так же)

Миниатюры

Ошибка include, измените includePath в VS code
 



0



0 / 0 / 0

Регистрация: 11.04.2013

Сообщений: 78

12.08.2020, 11:09

 [ТС]

20

Цитата
Сообщение от Алексей1153
Посмотреть сообщение

кстати, да, у тебя приложение то консольное?

ну, если консолька не выходит при запуске программы, значит не консольное?)
я попробовал добавил в код то что вы написали, всё так же)



0



Hello, so I am new to coding and wanted to use VS Code to code in C++, so I installed it, installed C/C++ IntelliSense v0.12.4 and followed instructions on the VS Code website to make a c_cpp_properties.json file and copied the code into it like they said. When I open my .cpp project that I had made in notepad++, I get the error:
«#include errors detected. Please update your includePath. IntelliSense features for this translation unit (directoryfile.cpp) will be provided by the Tag Parser. (9, 1)
cannot open source file «iostream» (9, 1)»

My .cpp code
`#include

using namespace std;

int main()
{
string firstName, lastName;
double hourRate, numHours;

    cout << "+----------------------------------------+" << endl;
    cout << " Your first name and last name: ";
    cin >> firstName >> lastName;
    cout << " Your hourly rate: ";
    cin >> hourRate;
    cout << " Number of hours worked last week: ";
    cin >> numHours;
    cout << endl;
    
    double regPay, overTPay, gPay, socSec, med, netPay;
    if (numHours <= 40)
    {
        regPay = hourRate * numHours;
        gPay = regPay;
        overTPay = 0;
    }
        else
        {
            double oTHours;
            oTHours = numHours - 40;
            regPay = hourRate * (numHours - (numHours - 40));
            overTPay = (hourRate * 1.5) * oTHours;
            gPay = regPay + overTPay;
        }
    socSec = gPay * 0.062;
    med = gPay * 0.0145;
    netPay = gPay - (socSec + med);
    cout << "+----------------------------------------+" << endl << endl;
    cout << " Pay Stubn" << " Regular pay  $" << regPay << endl;
    cout << " Overtime pay $" << overTPay << endl;
    cout << " Gross pay    $" << gPay << endl;
    cout << " Social Sec.  $" << socSec << endl;
    cout << " Medicare     $" << med << endl;
    cout << " Net Pay      $" << netPay << endl << endl;
    cout << "+----------------------------------------+" << endl << endl;
    cout << " Pay to: " << firstName << " " << lastName << endl;
    cout << " Total Pay: $" << netPay << endl << "ttt   ";
    cout << "Signed: P inc." << endl;
    cout << "+----------------------------------------+" << endl;
    
    return 0;
}`

My c_cpp_properties.json file

{
    "configurations": [
        {
            "name": "Mac",
            "includePath": [
                "/usr/include",
                "/usr/local/include",
                "${workspaceRoot}"
            ],
            "defines": [],
            "intelliSenseMode": "clang-x64",
            "browse": {
                "path": [
                    "/usr/include",
                    "/usr/local/include",
                    "${workspaceRoot}"
                ],
                "limitSymbolsToIncludedHeaders": true,
                "databaseFilename": ""
            },
            "macFrameworkPath": [
                "/System/Library/Frameworks",
                "/Library/Frameworks"
            ]
        },
        {
            "name": "Linux",
            "includePath": [
                "/usr/include",
                "/usr/local/include",
                "${workspaceRoot}"
            ],
            "defines": [],
            "intelliSenseMode": "clang-x64",
            "browse": {
                "path": [
                    "/usr/include",
                    "/usr/local/include",
                    "${workspaceRoot}"
                ],
                "limitSymbolsToIncludedHeaders": true,
                "databaseFilename": ""
            }
        },
        {
            "name": "Win32",
            "includePath": [
                "${workspaceRoot}"
            ],
            "defines": [
                "_DEBUG",
                "UNICODE"
            ],
            "intelliSenseMode": "msvc-x64",
            "browse": {
                "path": [
                    "${workspaceRoot}",
                    "C:/MinGW/lib/gcc/mingw32/6.3.0/include/c++",
                ],
                "limitSymbolsToIncludedHeaders": true,
                "databaseFilename": ""
            }
        }
    ],
    "version": 3
}

Also, when I hover over the «» this shows up:
«#include errors detected. Please update your includePath. IntelliSense features for this translation unit (E:StuffCS11-ThingsHomeworksA3paycheck.cpp) will be provided by the Tag Parser.
cannot open source file «iostream»»

Let me know if you need any more information

Hello, so I am new to coding and wanted to use VS Code to code in C++, so I installed it, installed C/C++ IntelliSense v0.12.4 and followed instructions on the VS Code website to make a c_cpp_properties.json file and copied the code into it like they said. When I open my .cpp project that I had made in notepad++, I get the error:
«#include errors detected. Please update your includePath. IntelliSense features for this translation unit (directoryfile.cpp) will be provided by the Tag Parser. (9, 1)
cannot open source file «iostream» (9, 1)»

My .cpp code
`#include

using namespace std;

int main()
{
string firstName, lastName;
double hourRate, numHours;

    cout << "+----------------------------------------+" << endl;
    cout << " Your first name and last name: ";
    cin >> firstName >> lastName;
    cout << " Your hourly rate: ";
    cin >> hourRate;
    cout << " Number of hours worked last week: ";
    cin >> numHours;
    cout << endl;
    
    double regPay, overTPay, gPay, socSec, med, netPay;
    if (numHours <= 40)
    {
        regPay = hourRate * numHours;
        gPay = regPay;
        overTPay = 0;
    }
        else
        {
            double oTHours;
            oTHours = numHours - 40;
            regPay = hourRate * (numHours - (numHours - 40));
            overTPay = (hourRate * 1.5) * oTHours;
            gPay = regPay + overTPay;
        }
    socSec = gPay * 0.062;
    med = gPay * 0.0145;
    netPay = gPay - (socSec + med);
    cout << "+----------------------------------------+" << endl << endl;
    cout << " Pay Stubn" << " Regular pay  $" << regPay << endl;
    cout << " Overtime pay $" << overTPay << endl;
    cout << " Gross pay    $" << gPay << endl;
    cout << " Social Sec.  $" << socSec << endl;
    cout << " Medicare     $" << med << endl;
    cout << " Net Pay      $" << netPay << endl << endl;
    cout << "+----------------------------------------+" << endl << endl;
    cout << " Pay to: " << firstName << " " << lastName << endl;
    cout << " Total Pay: $" << netPay << endl << "ttt   ";
    cout << "Signed: P inc." << endl;
    cout << "+----------------------------------------+" << endl;
    
    return 0;
}`

My c_cpp_properties.json file

{
    "configurations": [
        {
            "name": "Mac",
            "includePath": [
                "/usr/include",
                "/usr/local/include",
                "${workspaceRoot}"
            ],
            "defines": [],
            "intelliSenseMode": "clang-x64",
            "browse": {
                "path": [
                    "/usr/include",
                    "/usr/local/include",
                    "${workspaceRoot}"
                ],
                "limitSymbolsToIncludedHeaders": true,
                "databaseFilename": ""
            },
            "macFrameworkPath": [
                "/System/Library/Frameworks",
                "/Library/Frameworks"
            ]
        },
        {
            "name": "Linux",
            "includePath": [
                "/usr/include",
                "/usr/local/include",
                "${workspaceRoot}"
            ],
            "defines": [],
            "intelliSenseMode": "clang-x64",
            "browse": {
                "path": [
                    "/usr/include",
                    "/usr/local/include",
                    "${workspaceRoot}"
                ],
                "limitSymbolsToIncludedHeaders": true,
                "databaseFilename": ""
            }
        },
        {
            "name": "Win32",
            "includePath": [
                "${workspaceRoot}"
            ],
            "defines": [
                "_DEBUG",
                "UNICODE"
            ],
            "intelliSenseMode": "msvc-x64",
            "browse": {
                "path": [
                    "${workspaceRoot}",
                    "C:/MinGW/lib/gcc/mingw32/6.3.0/include/c++",
                ],
                "limitSymbolsToIncludedHeaders": true,
                "databaseFilename": ""
            }
        }
    ],
    "version": 3
}

Also, when I hover over the «» this shows up:
«#include errors detected. Please update your includePath. IntelliSense features for this translation unit (E:StuffCS11-ThingsHomeworksA3paycheck.cpp) will be provided by the Tag Parser.
cannot open source file «iostream»»

Let me know if you need any more information

I am using Visual Studio Code in my C++ project. I installed Microsoft C/C++ Extension for VS Code. I got the following error:

#include errors detected. Please update your includePath. IntelliSense features for this translation unit (/path/to/project/file.cpp) will be provided by the Tag Parser.

15 Answers

Tried these solutions and many others over 1 hour.
Ended up with closing VS Code and opening it again. That’s simple.

The answer is here: How to use C/Cpp extension and add includepath to configurations.

Click the light bulb and then edit the JSON file which is opened. Choose the right block corresponding to your platform (there are Mac, Linux, Win32 – ms-vscode.cpptools version: 3). Update paths in includePath (matters if you compile with VS Code) or browse.paths (matters if you navigate with VS Code) or both.

Thanks to @Francesco Borzì, I will append his answer here:

You have to Left 🖰 click on the bulb next to the squiggled code line.

If a #include file or one of its dependencies cannot be found, you can also click on the red squiggles under the include statements to view suggestions for how to update your configuration.

enter image description here

I ended up here after struggling for a while, but actually what I was missing was just:

If a #include file or one of its dependencies cannot be found, you can also click on the red squiggles under the include statements to view suggestions for how to update your configuration.

enter image description here

source: https://code.visualstudio.com/docs/languages/cpp#_intellisense

  • Left mouse click on the bulb of error line
  • Click Edit Include path
  • Then this window popup

enter image description here

  • Just set Compiler path

The error message «Please update your includePath» does not necessarily mean there is actually a problem with the includePath. The problem may be that VSCode is using the wrong compiler or wrong IntelliSense mode. I have written instructions in this answer on how to troubleshoot and align your VSCode C++ configuration with your compiler and project.

I was trying a hello world program, and this line:

#include <stdio.h>

was underlined green. I tried:

  1. Deleting the line
  2. Re-writing the line
  3. Clicking the yellow bulb and choosing to update

fixed the error warning. i don’t know if it fixed the actual problem. But then i’m compiling via a linux VM on Windows 10

If you are working with cmake-tools and the error messages says something is wrong with the configurationProvider, then following actions solved the issue for me:

  1. Open c_cpp_properties.json. (windows key on windows or cmd key on mac + shift + p, enter «c/c++ edit configurations» and chose ‘json’.
  2. Enter ms-vscode.cpptools as value for configurationProvider instead of ms-vscode.cmake-tools or whatever you have.

How it should look like after the replacement of configurationProvider:

enter image description here

One other important configuration is the include path. The assumption is that you have this configuration right. May be like following

enter image description here

After closing and reopening VS, this should resolve.

For me, using Ubuntu, I just had to install gcc to solve this issue.

sudo apt install gcc

Then, set the compiler path to gcc. Go to your c_cpp_properties.json file, set:

"compilerPath": "/usr/bin/gcc"
  • For Windows:

1.Install Mingw-w64

2.Then Edit environment variables for your account «C:mingw-w64x86_64-8.1.0-win32-seh-rt_v6-rev0mingw64bin»

3.Reload

  • For MAC

    1.Open search ,command + shift +P, and run this code “c/c++ edit configurations (ui)”

    2.open file c_cpp_properties.json and update the includePath from «${workspaceFolder}/**» to «${workspaceFolder}/inc»

In my case I did not need to close the whole VS-Code, closing the opened file (and sometimes even saving it) solved the issue.

Go to your c_cpp_properties.json file by searching from settings.There you might see the following code

{
    "configurations": [
        {
            "name": "Linux",
            "includePath": [
                "${workspaceFolder}/**"
            ],
            "defines": [],
            "compilerPath": "/usr/bin/gcc",
            "cStandard": "gnu17",
            "cppStandard": "c++17",
            "intelliSenseMode": "linux-gcc-x64"
        }
    ],
    "version": 4
}

Change the compiler path as below

"compilerPath": "/usr/bin/g++",

An alternative answer would be opening VS Code in remote WSL, if you going to compile files with g++. Just close your VS Code and open WSL and type code . After that the File Explorer shows that VS Code is now running in the context of WSL with the title bar [WSL: Ubuntu]. But make sure you’d installed the GNU compiler tools and the GDB debugger on WSL.

source: https://code.visualstudio.com/docs/cpp/config-wsl

For Windows:

  1. Please add this directory to your environment variable(Path):

C:mingw-w64x86_64-8.1.0-win32-seh-rt_v6-rev0mingw64bin

  1. For Include errors detected, mention the path of your include folder into

«includePath»: [
«C:/mingw-w64/x86_64-8.1.0-win32-seh-rt_v6-rev0/mingw64/include/» ]

, as this is the path from where the compiler fetches the library to be included in your program.

If someone have this problem, maybe you just have to install build-essential.

apt install build-essential

Понравилась статья? Поделить с друзьями:
  • Include expects filename or filename error
  • Include error detail postgre
  • Include error detail in the connection string
  • Inassimilable boot device windows 10 как исправить
  • Inaccessible boot device windows 2000 как исправить