How to Configure MSMPI for the MinGW-w64 Cross-Compiler
Jan. 9, 2012: Updated instructions for HPC Pack 2008 R2 MS-MPI Redistributable Package with Service Pack 3
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 2008 (cluster). Using the technique described here a modified version of OpenFOAM for Windows was configured with native MPI support.
Prerequisites
- Install MS-MPI Redistributable Package on Windows
- Install MinGW-w64 cross-compiler and gendef (from the MinGW-w64 project too) on Linux
Gather MPI distribution from Windows
Copy "C:\Program Files\Microsoft HPC Pack 2008 R2" to a temp location <msmpi-windows-home> (e.g., D:\projects\mpi\ms-hpc-2008-sp3) 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-2008-sp3) create libmsmpi.a using:
cd <msmpi-linux-home>/Lib/amd64gendef msmpi.dll- creates msmpi.defx86_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
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

