visual-studio-codecompiler-errorsmpiinclude-pathmpich

Updating includePath: Header file mpi.h cannot be found in Visual Studio Code under Windows 10


I am struggling to setup the MPI Framework using Visual Studio Code under Windows 10. I have downloaded MPICH for Windows from here and installed them following the instructions. I have just changed the standard installation path from C to D which shouldn't be a big deal.

Visual Studio Code and the MinGW compiler for C/C++ are already installed and up-to-date.

When I start MPI program in Visual Studio Code, the headerfile mpi.h is not found correctly. I get following error message:

#include errors detected. Please update your includePath. 
Squiggles are disabled for this translation unit (C:\xxx\code.cc) C/C++(1696)
cannot open source file "sal.h" (dependency of "mpi.h")C/C++(1696)

To update my includePath as described in the error message, I clicked on the light bulb:

Include error

I opened the c_cpp_properties.json file to modify the includePath section:

{
    "configurations": [
        {
            "name": "Win32",
            "includePath": [
                "${workspaceFolder}/**",
                "D:/Program Files (x86)/Microsoft SDKs/MPI/Include"
            ],
            "defines": [
                "_DEBUG",
                "UNICODE",
                "_UNICODE"
            ],
            "compilerPath": "C:/MinGW/bin/gcc.exe",
            "cStandard": "c11",
            "cppStandard": "c++17",
            "intelliSenseMode": "gcc-x64"
        }
    ],
    "version": 4
}

I added a new line D:/Program Files (x86)/Microsoft SDKs/MPI/Include in the includePath section. This is exactly the path where the header files are included. But for some reason, Visual Studio Code still shows me the include error from above. Why is that so? There is no "general" solution for this issue.

System environment variables should be fine. I was able to compile/run OpenMP programms as well.


Solution

  • Everything works fine now.

    I have just deleted and then reinstalled Visual Studio Code.

    That solved the issue.