VS Code unable to detect Standard C++ Libraries

14,589

Solution 1

VS Code need to locate the include libraries.

  1. First of all locate where g++ is located. You mentioned that it works fine. It's an .exe file (windows). So you may find g++ directory in path settings. view path variables.

  2. Now after getting g++.exe directory you may easily find a file names string in nearby folders or parent folders. After successfully locating it copy its full path.

  3. Now back in VS Code put cursor over green underline and you should see a bulb. Click it and in the options you will see option Edit "includePath" setting or Update "browse.path" setting. Select it and a file will open named c_cpp_properties.json

  4. Now in that file locate "name": "win32". In the include path option paste the directory name of string file like this and you are good to go.

like this

Solution 2

In vscode go to file>preferences>settings then select edit in settings.json (This can be hard to find, certain settings have this option by them, others do not. There is probably a better way to access this file, but I don't know it)

This will open up the settings.json file, where you can add the line:

    "C_Cpp.default.includePath": ["C:\\Program Files (x86)\\Microsoft Visual Studio 14.0\\VC\\include"]

(or whatever your include path is) This will add that include path for all projects, or only the current workspace depending on if you open the settings.json file for "User Settings" or for "Workspace Settings"

Share:
14,589
Robb
Author by

Robb

Games, GNU/Linux, and programming lover. Trying to make the three of them work together!

Updated on June 04, 2022

Comments

  • Robb
    Robb almost 2 years

    I started using VS Code, and after messing around with it I kind of managed to make it detect Windows and Direct3D SDK's with the c_cpp_properties.json, but I'm failing to make the Standard Library work. So, if I do:

    #include <string>
    #include <vector>
    

    It throws me an error just like this:

    //Include file not found in include path
    

    I've searched all over the web and didn't find any clue, so here I am! Strangely enough, if I just create a new .cpp file in an empty window/editor, it works. But the moment I 'load' the folder that file is in, then it fails. So, this is really driving me crazy.

    I'm using Windows 10, with .NET 4.6.2, the 2015 Visual C++ Redist, and the Windows 10 SDK, all blazing new installs from today. My ultimate goal is to port a project I made in VS2013 to GNU/Linux, so I'm trying to make things work step by step.

    Thanks a lot beforehand!

    EDIT: Compiling with g++ works just fine, even though VS Code complains. This is what happens.