How to Fix VS Code and C++ IntelliSense Not Working or Picking Up Libraries on Windows 11

VS Code’s IntelliSense is what makes coding fast and productive — it helps you with auto-completion, syntax highlighting, function hints, and error detection. But when it stops detecting your headers or libraries, you’ll see annoying red squiggles like:

#include errors detected. Please update your includePath. or, cannot open source file “iostream”

If you’re seeing errors like these, it usually means your compiler or include paths aren’t configured correctly. Let’s fix that step-by-step.

Why IntelliSense Stops Working

Here are the most common reasons IntelliSense fails to pick up C++ libraries in VS Code:

  • The C/C++ extension isn’t installed or configured.
  • Missing or incorrect include paths in c_cpp_properties.json.
  • Compiler (like MinGW) isn’t installed or not added to PATH.
  • Your project doesn’t have a valid workspace or folder structure.
  • IntelliSense database is corrupted or outdated.

Let’s fix each issue one by one.

Step 1: Install the Microsoft C/C++ Extension

VS Code doesn’t include C++ IntelliSense by default — you need the official Microsoft C/C++ extension.

  1. Open VS Code.
  2. Go to the Extensions tab (Ctrl + Shift + X).
  3. In the search bar, type: C/C++
  4. Install the extension by Microsoft (it’s usually the first result).
  5. Restart VS Code after installation.

Tip: If you already have it, click Reload or Update if an update is available.

Step 2: Install a C++ Compiler (MinGW or MSVC)

IntelliSense relies on your compiler to locate system libraries (like <iostream> or <vector>). If your compiler isn’t installed, VS Code won’t know where to look.

Option 1 – Install MinGW (Recommended for beginners):

  1. Go to https://www.mingw-w64.org/.
  2. Download the MinGW-w64 installer.
  3. During setup, choose:
    • Architecture: x86_64
    • Threads: posix
    • Exception: seh
  4. Once installed, add MinGW to PATH manually: C:\mingw64\bin
  5. Restart your PC and verify installation: g++ --version You should see version info displayed.

Option 2 – Use Microsoft’s MSVC Compiler (for advanced users):

Install Visual Studio Community Edition and include the Desktop development with C++ workload.

Step 3: Set the Compiler Path in VS Code

Now that your compiler is ready, tell VS Code where to find it.

  1. Open your C++ project folder in VS Code.
  2. Press Ctrl + Shift + P, then search for: C/C++: Edit Configurations (UI)
  3. Under Compiler Path, click Browse and navigate to your compiler’s executable: C:\mingw64\bin\g++.exe
  4. Save the settings and restart VS Code.

Now IntelliSense knows exactly where to find your compiler.

Step 4: Fix includePath in c_cpp_properties.json

If IntelliSense still isn’t picking up standard libraries or your custom headers, you’ll need to fix the includePath configuration file.

  1. Go to your project folder.
  2. Inside the hidden .vscode folder, open the file: c_cpp_properties.json
  3. Find and edit this section: { "configurations": [ { "name": "Win32", "includePath": [ "${workspaceFolder}/**", "C:/mingw64/include", "C:/mingw64/x86_64-w64-mingw32/include", "C:/mingw64/lib/gcc/x86_64-w64-mingw32/12.2.0/include" ], "compilerPath": "C:/mingw64/bin/g++.exe", "cStandard": "c17", "cppStandard": "c++20", "intelliSenseMode": "windows-gcc-x64" } ], "version": 4 }
  4. Save the file and restart VS Code.

Tip: Adjust version numbers in the path depending on your MinGW installation.

Step 5: Rebuild IntelliSense Index

Sometimes IntelliSense’s internal database becomes outdated or corrupted.

  1. Press Ctrl + Shift + P and run: C/C++: Reset IntelliSense Database
  2. Then run: C/C++: Rescan Workspace
  3. Wait for a few seconds — you should see IntelliSense begin working again.

Step 6: Ensure You Open the Correct Folder

If you open a single .cpp file instead of your project folder, VS Code won’t load the configuration files properly.

  • Always open the root folder of your project (File → Open Folder…), not just an individual file.
  • This ensures VS Code loads .vscode settings, tasks.json, and launch.json.

Step 7: Check for Multiple Configurations

If you’ve created multiple configurations (like Debug and Release), ensure the correct one is selected.

  1. Look at the bottom-right corner of VS Code.
  2. Make sure it says something like “Win32” or “GCC x64”.
  3. If it’s showing an old configuration, click it and select your preferred one.

Step 8: Update the C/C++ Extension

Outdated IntelliSense engines can cause unpredictable behavior.

  1. Open the Extensions tab (Ctrl + Shift + X).
  2. Locate C/C++ by Microsoft.
  3. Click Update if available.
  4. Restart VS Code.

After updating, IntelliSense usually reinitializes correctly.

Step 9: Add Custom Library Paths (Optional)

If you’re using custom libraries (like SFML, OpenCV, etc.), IntelliSense needs to know where their headers are located.

Example (for OpenCV):

In c_cpp_properties.json, add:

"C:/opencv/build/include"

and for libraries:

"C:/opencv/build/x64/vc15/lib"

After that, IntelliSense should recognize the headers and functions.

Step 10: Restart VS Code or Your PC

After all the configuration changes, restarting VS Code (or even your system) ensures that PATH, compiler, and IntelliSense settings refresh correctly.

Wrapping Up

When IntelliSense stops working in VS Code, it’s almost always a configuration issue — missing compiler paths, broken include paths, or outdated settings.

By ensuring your compiler (MinGW or MSVC) is properly installed, updating your includePath configuration, and rebuilding IntelliSense, you can restore full functionality and get back to efficient, smart C++ coding.

Once everything is set up, VS Code becomes a powerful and lightweight alternative to full IDEs — offering smooth IntelliSense, debugging, and build automation in a clean, modern interface.

Posted by Arpita

With a background in Computer Science, she is passionate about sharing practical programming tips and tech know-how. From writing clean code to solving everyday tech problems, she breaks down complex topics into approachable guides that help others learn and grow.