Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Visual Studio Code include file not found in include directory (Windows 10)

I am trying to get intellisense in Visual Studio Code. I downloaded the the C/C++ extension from the marketplace: https://marketplace.visualstudio.com/items?itemName=ms-vscode.cpptools and also installed MinGW with the packages mingw32-base and mingw32-gcc-c++. I added the MinGW bin folder to Path in my Environment variables.

When I add any include statement in my .c file, such as #include <stdio.h>, Visual Studio Code says:

Include file not found in include directory

Am I not configuring correctly? How can I get intellisense for C/C++?

like image 970
syy Avatar asked Sep 10 '16 20:09

syy


People also ask

How do I fix No such file or directory in Visual Studio Code?

Try reinstalling mingw. Basically, the problem is with header files. I think you should try reinstalling mingw, adding it to system path again or try installing the extension in vscode. Hope this helped.

How do I manually add VS Code to path?

Launch VS Code. Open the Command Palette (Cmd+Shift+P) and type 'shell command' to find the Shell Command: Install 'code' command in PATH command.

How do I show a directory in VS Code?

Open VSCode application or open a new VSCode window if the current session is to be preserved. Navigate to "Open Folder", either via File menu or Ctrl + K + O. Navigate to the folder and select it for opening.


2 Answers

On Fedora linux I added the following path where all my c header files lives.

/usr/include/**

to myc_cpp_properties.json file.

{
    "configurations": [
        {
            "name": "Linux",
            "includePath": [
                "${workspaceFolder}/**",
                "/usr/include/**"
            ],
            ...
        }
    ],
    "version": 4
}
like image 156
Marcel Zebrowski Avatar answered Sep 23 '22 19:09

Marcel Zebrowski


  1. First, make sure to create a c_cpp_properties.json file in your .vscode folder

    Hint: Use the Command Palette (Ctrl+Shift+P) and type C/Cpp: Edit Configurations

  2. Add include paths like this:

    {
      "configurations": [
        {
          "name": "Win32",
          "includePath": [
            "path_to_your/MinGW/lib/gcc/mingw32/4.8.1/include/c++"
          ],
          "browse": {
            "limitSymbolsToIncludedHeaders": true,
            "databaseFilename": ""
          }
        }
      ]
    }
    
like image 22
wbmrcb Avatar answered Sep 21 '22 19:09

wbmrcb