OpenFOAM v3.0+ on Windows

We have updated our free Windows source code patch for OpenFOAM® v3.0+ with support by BIM HVACTool (Tian Building Engineering). This patch uses the MinGW-w64 cross-compiler with the option for parallel computation using the native Windows MS MPI implementation provided by the free Microsoft MPI Redistributable.


Are you looking for a GUI driven, integrated simulation environment for Windows, Linux, and Mac incorporating a selection of the RANS OpenFOAM solvers and various import/export filters?

Caedium Professional

Get Started With Caedium Now

Patch Build Process

To build OpenFOAM for Windows with a cross-compiler requires expert knowledge of Windows and Linux utilities and compilers.

The following steps are required to produce a native Windows version of OpenFOAM with [optional] native Windows MS MPI:

  1. Install MinGW-w64 cross-compiler and zlib on Linux
  2. Install zlib files into following locations:
    • /usr/lib/gcc/x86_64-w64-mingw32/<mingw-version>/include/zconf.h
    • /usr/lib/gcc/x86_64-w64-mingw32/<mingw-version>/include/zlib.h
    • /usr/lib/gcc/x86_64-w64-mingw32/<mingw-version>/libz.a
    • /usr/lib/gcc/x86_64-w64-mingw32/<mingw-version>/libz.dll.a
    • /usr/lib/gcc/x86_64-w64-mingw32/<mingw-version>/zlib1.dll
  3. [optional] Create libmsmpi.a from Microsoft MPI Redistributable
  4. Install the OpenFOAM v3.0+ source distribution on Linux.
  5. Patch (using the Linux patch command) the OpenFOAM v3.0+ source distribution with our MinGW Windows modifications
  6. At various stages during this process you will need to set OpenFOAM MinGW-w64 environment variables and source etc/bashrc. As an example:
    export FOAM_INST_DIR="$(HOME)/projects/of/3.0"; source $(FOAM_INST_DIR)/OpenFOAM-plus-3.0.x/etc/bashrc WM_OSTYPE=MSwindows WM_COMPILER=mingw-w64 WM_ARCH_OPTION=64 WM_PRECISION_OPTION=SP WM_CC=x86_64-w64-mingw32-gcc WM_CXX=x86_64-w64-mingw32-g++ compilerInstall=system [optional] WM_MPLIB=MSMPI [optional] MPI_ARCH_PATH="$(HOME)/projects/msmpi/install"
  7. [optional] Install the ThirdParty-v3.0+ source and build scotch according to:
    1. ln -s ThirdParty-v3.0+ $(WM_THIRD_PARTY_DIR)
    2. ln -s $(WM_THIRD_PARTY_DIR)/scotch<version> $(WM_THIRD_PARTY_DIR)/scotch
    3. ln -s $(WM_PROJECT_DIR)/extra/scotch/src/ $(WM_THIRD_PARTY_DIR)/scotch/src/
    4. cp $(WM_PROJECT_DIR)/extra/scotch/src/libscotch/* $(WM_THIRD_PARTY_DIR)/scotch/src/libscotch/.
    5. cd $(WM_THIRD_PARTY_DIR)/scotch/src
    6. cp $(WM_PROJECT_DIR)/extra/scotch/src/Makefile .
    7. make libscotch
    8. mkdir -p $(FOAM_LIBBIN)
    9. cd $(WM_THIRD_PARTY_DIR)/scotch/src/libscotch
    10. cp libscotch.* $(FOAM_LIBBIN)
  8. To build OpenFOAM:
    1. source the OpenFOAM native linux environment variables
    2. cd $(WM_PROJECT_DIR)/wmake/src; make
    3. ln -s $(WM_PROJECT_DIR)/wmake/platforms/linux64Gcc $(WM_PROJECT_DIR)/wmake/platforms/linux64mingw-w64
    4. source the OpenFOAM MinGW-w64 environment variables
    5. cd $(WM_PROJECT_DIR);./Allwmake
  9. Transfer the OpenFOAM etc directory ($(WM_PROJECT_DIR)/etc), executables ($(WM_PROJECT_DIR)/platforms/linux64mingw-w64*/bin/*.exe), and libraries ($(WM_PROJECT_DIR)/platforms/linux64mingw-w64*/lib/*.dll and $(WM_PROJECT_DIR)/platforms/linux64mingw-w64*/lib/*/*.dll) to the Windows computer
  10. Transfer the MinGW-w64 libraries:
    • /usr/lib/gcc/x86_64-w64-mingw32/<mingw-version>/*.dll
    • /usr/x86_64-w64-mingw32/lib/*.dll

    to the Windows computer

  11. On the Windows computer ensure the following environment variables are set:
    • The WM_PROJECT_DIR and USERNAME variables are set.
    • The PATH variable is set to include the OpenFOAM executable and library locations (including $(WM_PROJECT_DIR)/lib/linux64mingw-w64*/dummy or [optional] $(WM_PROJECT_DIR)/lib/linux64mingw-w64*/msmpi).
  12. Launch a Windows command prompt to run OpenFOAM solvers and utilities, such as simpleFoam.exe.


  • With this method of building OpenFOAM for Windows the job control scripts in $(WM_PROJECT_DIR)/bin (such as foamSolverSweeps) are unavailable.
  • The libccmio library is not built.
  • Supports bashrc only, i.e., no cshrc support.


  • OpenFOAM is a registered trademark of OpenCFD and is unaffiliated with Symscape
  • The OpenFOAM Windows patch provided here is licensed under the GNU Public License (GPL)