1

I'm working on a university project where I have to use MPI( Message Passing Interface) for parallel programming. I will be using the language C as a background, and I did all the setup for C in my VS Code and the programs of C worked fine. For MPI I needed to install the msmpisdk wrapper with executable msmpisetup for the setup, I added the path of the bin file in my environment variables C:\Program Files\Microsoft MPI\Bin, however my VScode doesn't recognize the mpi library in my code showing me this error : mpi.h: No such file or directory 2 | #include <mpi.h>

I searched for a solution all the day but failed !

Do you have any ideas how I can fix that please ?

I have windows 10

katmanco
  • 1,146
  • 12
  • 24
  • You must include the path where the mpi.h header file is present in your "Additional Include directories" in Visual Studio, refer this [page](https://devblogs.microsoft.com/cppblog/a-tour-of-cpp-modules-in-visual-studio/#external-modules) – Anand Sowmithiran Dec 07 '21 at 09:48
  • thank you for answering, but I want to install the mpi in my Vscode and not in visual studio, I did add the path in my environment variables of mpi sdk file but still didn't work! for visual studio it's easy to do it but I dont know if it's possible in vs code because I prefer work on it instead of installing visual studio... – Data science folk Dec 08 '21 at 11:46
  • For VS Code, you can modify the include path such that it includes the path where the mpi header files are present. You need to edit the file c_cpp_properties.json, and the `C_Cpp.default.includePath` element. – Anand Sowmithiran Dec 08 '21 at 12:46
  • Refer more details on configuring that `includePath` in this SO [answer](https://stackoverflow.com/a/58839719/14973743) – Anand Sowmithiran Dec 08 '21 at 12:52
  • were you able to configure the include path in VS code and compile? – Anand Sowmithiran Dec 10 '21 at 14:26
  • Heey @AnandSowmithiran Thank you for the answer, i moved to visual studio instead of VScode but i will try the solution you gave me and let you know if it works (y) – Data science folk Dec 10 '21 at 20:16

1 Answers1

0

If you are using VS Center image description hereode, you just need to add a simple line to c_cpp_properties.json. This file can be found under the .vscode folder in your project root directory. Under configurations edit includePath to have:

"includePath": [
            "${workspaceFolder}/**",
            "C:/Program Files (x86)/Microsoft SDKs/MPI/Include"
        ],