How to Configure MSMPI for the MinGW-w64 Cross-Compiler

For the latest version of these instructions visit "How to Configure MS-MPI v8.1 for the MinGW-w64 Cross-Compiler".

Jan. 21, 2013: Updated instructions for HPC Pack 2012 MS-MPI Redistributable Package

Here you'll find the instructions on how to create libmsmpi.a for the MinGW-w64 cross-compiler to link against for MPI applications, given the free MS-MPI Redistributable Package. Once configured with the msmpi library an MPI application can run in parallel on a multi-core Windows machine or in parallel on Microsoft Windows HPC Server (cluster). Using the technique described here a modified version of OpenFOAM for Windows was configured with native MPI support.


Gather MPI distribution from Windows

Copy C:\Program Files\Microsoft HPC Pack 2012 to a temp location <msmpi-windows-home> (e.g., D:\projects\mpi\ms-hpc) then copy C:\Windows\System32\msmpi.dll to <msmpi-windows-home>\Lib\amd64\.

Transfer <msmpi-windows-home> to Linux.

Create libmsmpi.a on Linux

Assuming the MSMPI distribution copied over from Windows, in the previous step, is located at <msmpi-linux-home> (e.g., $HOME/projects/msmpi/ms-hpc) create libmsmpi.a using:

  • cd <msmpi-linux-home>/Lib/amd64
  • gendef msmpi.dll - creates msmpi.def
  • x86_64-w64-mingw32-dlltool -d msmpi.def -l libmsmpi.a -D msmpi.dll - creates libmsmpi.a

Fix missing __int64 definition

You will need to add #include <stdint.h> to <msmpi-linux-home>/Inc/mpi.h:127 to define __int64.

Set compiler flags for user code

Compile in Linux using MinGW-w64 (e.g., x86_64-w64-mingw32-gcc) with compiler flags:

  • -I<msmpi-linux-home>/Inc
  • -L<msmpi-linux-home>/Lib/amd64
  • -lmsmpi


Would you be able to help with the MinGW 64bit gfortran also?

I was wondering if you would be able to give the same instructions to use MS MPI with MinGW 64-bit gfortran also? I tried to duplicate, but did not work with my method.

Thank you.

Nevermind, this solution did

Nevermind, this solution did actually work for gfortran also. Thank you for this 2 year old post :)

one can also extract the msi file directly in linux

this does not require a windows machine :

7z x mpi_64.msi
gendef msmpi64.dll
x86_64-w64-mingw32-dlltool -d msmpi64.def -l libmsmpi.a -D msmpi64.dll

Hi, Thanks for the great


Thanks for the great instructions. Can you list the full compiler command in the very last step? what files are we compiling here, and what is the output?


Compiler flags for compiling your own code

The final step is not part of the preparation, it's the compiler/linker flags to use when compiling your own code.