microsoft / Microsoft-MPI

Microsoft MPI
MIT License
246 stars 74 forks source link

How to include MSMPI in VsCode? #13

Open 543877815 opened 5 years ago

543877815 commented 5 years ago

I config my vscode following this blog , and I changed the “code run - setting.json” like

"cpp": "cd $dir && g++ $fileName -o $fileNameWithoutExt -fopenmp -l msmpi -L \"C:\\Program Files (x86)\\Microsoft SDKs\\MPI\\Lib\\x64\" -I \"C:\\Program Files (x86)\\Microsoft SDKs\\MPI\\Include\" && mpiexec -n 4 $dir$fileNameWithoutExt",

Is that wrong? I tried to include mpi.h but something wrong happened, like

C:\Users\PC\AppData\Local\Temp\ccOw0hGm.o:main.cpp:(.text+0x4c): undefined reference to `MPI_Init@8'
C:\Users\PC\AppData\Local\Temp\ccOw0hGm.o:main.cpp:(.text+0x62): undefined reference to `MPI_Comm_rank@8'
C:\Users\PC\AppData\Local\Temp\ccOw0hGm.o:main.cpp:(.text+0x78): undefined reference to `MPI_Comm_size@8'
C:\Users\PC\AppData\Local\Temp\ccOw0hGm.o:main.cpp:(.text+0x90): undefined reference to `MPI_Get_processor_name@8'
C:\Users\PC\AppData\Local\Temp\ccOw0hGm.o:main.cpp:(.text+0x115): undefined reference to `MPI_Finalize@0'
collect2.exe: error: ld returned 1 exit status

and the code #include <mpi.h> in main.cpp also showed the error

#include errors detected. Please update your includePath. Squiggles are disabled for this translation unit.
cannot open source file "mpi.h"

emm... maybe this package can only run in Visial Studio 2017?? I tried to include it in clion(cmake) firstly but I failed, either. I just don't want to install VS due to its huge size.

Qjbtiger commented 4 years ago

From this blog https://unordered.org/timelines/5a23942358800000, it seem that the problem is some necessary files were included in vs software while were not included in msmpi. So I think one of the solution is to use openmpi instead of msmpi.

Moharudrakg commented 3 years ago

I have tried everything on windows to have smooth sailing with MPI program but nothing works so i came up with this 100% working solution.... But you need to install : 1.Virtual box or VMWare workstation 2. Ubuntu OS Image(In my case i have only used Ubuntu without gui). After booting os next step is you just need to type commad to install MPI -> sudo apt install openmpi-bin libopenmpi-dev

Now you can write program in c or c++ to Compile C-MPI Program : mpicc program.c -o outputbinaryfile to run file use : mpirun -n outputbinaryfile