How to Configure MS-MPI v8.1 for the MinGW-w64 Cross-Compiler
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 v8.1 and the MS-MPI SDK v8.1. Once configured with the msmpi library an MPI application can run in parallel on a multi-core Windows machine. Using the technique described here a modified version of OpenFOAM for Windows was configured with native MPI support.
Prerequisites
- Install MS-MPI Redistributable Package (MSMpiSetup.exe) and MS-MPI SDK (msmpisdk.msi) 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 (x86)\Microsoft SDKs\MPI
to a temp location <msmpi-windows-home> (e.g., D:\projects\mpi\ms-mpi
) then copy C:\Windows\System32\msmpi.dll
to <msmpi-windows-home>\Lib\x64\.
Transfer <msmpi-windows-home> to Linux.
Create libmsmpi.a on Linux
Assuming the MS-MPI distribution copied over from Windows, in the previous step, is located at <msmpi-linux-home> (e.g., $HOME/projects/msmpi/ms-mpi
) create libmsmpi.a using:
cd <msmpi-linux-home>/Lib/x64
gendef msmpi.dll
- creates msmpi.defx86_64-w64-mingw32-dlltool -d msmpi.def -l libmsmpi.a -D msmpi.dll
- creates libmsmpi.a
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>/Include
-L<msmpi-linux-home>/Lib/x64
-lmsmpi