OpenFOAM 1.6.x on Windows

For the latest version of our Windows patch for OpenFOAM visit "OpenFOAM 2.2.x on Windows".

We have updated our Windows patch for OpenFOAM to match the latest OpenFOAM release (v1.6.x). Be warned - to build OpenFOAM for Windows with a cross compiler requires expert knowledge of Linux utilities and compilers.


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? Then try our Caedium RANS Flow add-on.

Get Started With Caedium Now

Patch Build Process

The following steps are required to produce a native Windows version of OpenFOAM 1.6.x using a cross compiler:

  1. Configure, build, install and test a MinGW cross compiler for Windows running on Linux. I used the script.
  2. Add #include_next <float.h> to the end of
    lib/gcc/mingw32/4.4.1/include/float.h and remove it from
    mingw32/include/float.h to include the right float.h.
  3. Install the OpenFOAM 1.6.x source distribution on Linux - git Commit: 50d2858505ca00e44776ce89cab97f9a33f098e8 Date: Dec 2 15:26:12 2009.
  4. Patch (using the Linux patch command) the OpenFOAM 1.6.x source distribution with our MinGW Windows modifications [last updated March 5, 2010 to v10].
  5. Copy wmkdep and dirToString from wmake/bin/linuxGcc to wmake/bin/linuxmingw32.
  6. Export environment variables and source etc/bashrc. As an example:
    export FOAM_INST_DIR="$HOME/projects/of/of1.6"
    export WM_ARCH_OPTION=32
    export WM_OSTYPE=MSwindows
    export WM_COMPILER=mingw32
    export WM_CC=mingw32-gcc
    export WM_CXX=mingw32-g++
    export compilerInstall=System
    export WM_MPLIB=NONE
    source "$FOAM_INST_DIR/OpenFOAM-1.6.x/etc/bashrc"
  7. Build using Allwmake in the OpenFOAM-1.6.x directory on Linux.
  8. Transfer the OpenFOAM executables (applications/bin/linuxmingw32*/*.exe) and libraries (lib/linuxmingw32*/*.dll) to the Windows computer.
  9. Launch a Windows command prompt to run OpenFOAM solvers and utilities, such as simpleFoam.exe.

On the Windows computer ensure the following:

  • The WM_PROJECT_DIR and USERNAME variables are set.
  • The etc directory from the original source distribution is within the WM_PROJECT_DIR.
  • The PATH variable is set to include the OpenFOAM executable and library locations.


With this method of building OpenFOAM for Windows the following features (there maybe more) are unavailable:

  • job control scripts in bin (such as foamSolverSweeps)
  • parallel

The following applications and libraries are unlikely to build:

  • libccmio
  • Scotch, metis, MPI and any dependents




thank for your patch for OpenFOAM 1.6.x and Windows. I compiled OpenFOAM for windows and it seems like it is working, BUT if I tried to use the solver in windows command prompt, I got this error:

FOAM FATAL ERROR in Foam::findEtcFile<> : could not find mandatory file 'controlDict'

I set up all PATH variable. The etc directory from the original source distribution is within the WM_PROJECT_DIR also.

Maybe you have some advice???


Check etc/controlDict

So you've set the environment variable WM_PROJECT_DIR and you have the etc directory within WM_PROJECT_DIR. Next ensure that the file WM_PROJECT_DIR/etc/controlDict is in place and valid. Just for reference the etc directory should contain:

  • cellModels
  • controlDict
  • thermoData/BurcatCpData
  • thermoData/therm.dat

Another thought, is to try using Wine under Linux while you are chasing this problem to avoid copying files backwards and forwards.

Hope this helps.



it is working now! I used it in MS Command Prompt as follow:

"set WM_PROJECT_DIR=C:\Simulation\OpenFOAM-1.6.x"

Thanks really a lot!




and thanks for the patch.

Do you have a script to build your patch automatically? I want try to build a MS Windows version of OpenFOAM-1.5-dev also. Maybe you have a path for this version already?1


Didn't Try OpenFOAM-1.5-dev

Sorry I don't have an automatic patch applying-building script.

The old OpenFOAM 1.5.x patch is still available, but I haven't tried applying it to OpenFOAM-1.5-dev.



great job for all the patches! Did you also tried the mingw64?


Not Yet

I haven't tried mingw64. If you try it be sure to report back, thanks.

OpenFOAM-1.5-dev and windows

Did you successful build a MS Windows version of OpenFOAM-1.5-dev?I'm more interested in it!

Thank you !

No Longer Supporting 1.5.x

No, I'm no longer supporting the 1.5.x patch. For more see "Didn't Try OpenFOAM-1.5-dev"

Proposed additional fixes and mingw64


Just dropping by to:

  • say thanks for the patches and tutorial!
  • report I've been patching up OpenFOAM 1.6 and cross-compiling with mingw-w64 (also with mingw-w32 and mingw32), and maintaining a wiki page at, here.
  • The most recent patch in that wiki page is based on the patch v9 version of yours, and I've discovered at least two more things missing:
    • The multiphaseInterFoam solver also needs a "Foam::interfaceProperties::initRunTime();" to force interfaceProperties to load at run time;
    • At this section of the wiki, I described what needs to be done to get chtMultiRegionFoam to run properly in Windows, with minor adjustments. I did try the "IOobject::replaceFileName" you've had since 1.5.x, but it didn't work for me.

Best Regards,

Thanks for the Update

Great work Bruno, getting parallel up and running, the 64-bit compilation, and the documentation on OpenFOAMWiki.

Thanks too for the feedback on the issues you found with the current (v9) 1.6.x patch.