71
votes

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
generally self-answered questions are ok, but then you should write a clear question and an anwer that is more than just a link to an external resource.jps
In Mac OS, installing xcode command line tools using xcode-select --install and then restarting vscode solved the problem for me.zdm
For Linux users: Make sure you have g++ installed.Farbod Ahmadian

15 Answers

60
votes

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

55
votes

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

14
votes

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

12
votes
  • 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
9
votes

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.

4
votes

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

2
votes

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

1
votes

After closing and reopening VS, this should resolve.

1
votes

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"
0
votes

1.Install Mingw-w64

2.Then Edit environment variables for your account "C:\mingw-w64\x86_64-8.1.0-win32-seh-rt_v6-rev0\mingw64\bin"

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"

0
votes

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.

0
votes

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++",
0
votes

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

-1
votes

For Windows:

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

C:\mingw-w64\x86_64-8.1.0-win32-seh-rt_v6-rev0\mingw64\bin\

  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.

-1
votes

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

apt install build-essential