Installation/Windows/Outdated/Tip Cross Compiling OpenFOAM in Linux For Windows with MinGW
This is an exhaustive step by step guide on how to fully cross-compile OpenFOAM in Linux for Windows, for both 32 and 64 bits architectures (from and to), using the patches made available in each respective page. NOTE: for cross-compiling in Cygwin for Windows, see the page Using Cygwin for cross-compiling OpenFOAM.
These patches were initially based on Symscape's "v3" patch for OpenFOAM 1.5.x available here, but as development evolves, occasional updates are made based on the latest patches by Symscape. Symscape's patches differ substantially from the patches available on this wiki; the main differences of the patches on this wiki are:
- these aim to build OpenFOAM up to 100% of its original capabilities;
- these also build most Third Party tools that OpenFOAM can use directly (Scotch, Metis);
- provide additional scripts for building OpenFOAM and the maintenance of these patches;
- target only Windows - Symscape's patches also have changes for Mac OS X;
- these patches are only released for each major release of OpenFOAM - Symscape's patches are updated every 2-3 months.
With this guide and available patches, you should be able to cross-compile the whole and complete OpenFOAM libraries and applications, using MPICH2 instead of Open MPI for parallel computing. You can cross-compile using mingw32 and/or mingw-w64.
2 Patch versions
With the release of OpenFOAM 1.7 and the separate evolution of the patches for each OpenFOAM version, the once single wiki page will now branch into 3 parts:
- This page will have the relevant information for all patch versions
- One page for each patch version:
Support for these patches is available at OpenFOAM's forum here.
3 Information common to all patch versions
3.1 Building Paraview in Windows
Since ParaView 3.8.0 was released , it no longer seems necessary to put effort into building ParaView with MPICH2 and the native OpenFOAM reader. Kitware now provides ParaView with (and without) MS-MPI for parallel functionality, and the plugin from here is already integrated.
Either way, in case you really want to build ParaView, the following instructions are the ones initially written on this wiki page:
- This is a pain to do, and yet, quite simple once you get the handle of it. Nonetheless, here won't be described the full building procedure. You can follow the tutorial available here in this wiki and use that plug-in for reading .foam files directly from Paraview, without building the original plug-ins that come with OpenFOAM and be able to handle large and/or parallelized cases. On that tutorial page, you also have a link to an already built version of Paraview 3.4.0 with the plug-in. This way it is less one thing to worry about building.
- Tips for building a 64bit version of Paraview - Follow the instructions available here and here. This way you can get Visual Studio Express to build x64 applications and also build Qt 64bit for Windows, as well as Paraview with the multi-platform plug-in!
3.2 Using MPICH2 with OpenFOAM in Windows
This is valid for each computer with Windows, where you installed the cross-compiled OpenFOAM. Be advised that you should install OpenFOAM in an identical folder path on each machine, or in a network shared drive. User accounts of the same name and password will reduce the complexity of your system. Currently we haven't tested running with different user accounts.
NOTE: these steps depend on the MPICH2 version you choose to run, namely 32 or 64bit. So you might need to do them every time you need different architectures. Nonetheless, the SMPD service seemed to be compatible with both versions.
The steps are:
- Go to into your administrative account (if your user account doesn't have administrative capabilities) and:
- Open a command line (Start->Run... or Winkey+R and run cmd.exe).
- Go to the bin folder where MPICH2 is installed (e.g. cd C:\Program Files\MPICH2\bin).
smpd -installto install the MPICH2 smpd service.
- Now run the OpenFOAM terminal (double click on the file DOS_Mode.bat).
And when it asks your user name just press Enter key; and when it asks your user password, introduce your password... it'll ask you twice to make sure. This will allow future calls to mpiexec to be done without requiring password. MPICH will encrypt your password into the Windows Registry, so it should be safe.CAUTION: the MSys terminal version will make your password visible on screen!
- Test the parallel system. For that, you'll have to:
- In the OpenFOAM terminal, go to the folder ofuser-1.6 (or $USER-1.6) and unpack the test case PTestCase.tar.gz;
- Go into the pTestCase case folder;
gompi parallelTestIt will test communications between two instances of parallelTest.exe. If successful, it should display something like this:
C:\Program Files\blueCFD\ofuser-1.6\PTestCase>mpiexec -n 2 -genvlist HOME,PATH, USERNAME,WM_PROJECT_DIR,WM_PROJECT_INST_DIR,WM_OPTIONS,FOAM_LIBBIN,FOAM_APPBIN, FOAM_USER_APPBIN,MPI_BUFFER_SIZE parallelTest -parallel /*---------------------------------------------------------------------------*\ | ========= | | | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | | \\ / O peration | Version: 1.6 | | \\ / A nd | Web: www.OpenFOAM.org | | \\/ M anipulation | | \*---------------------------------------------------------------------------*/ /* Windows 32 and 64 bit porting by blueCAPE: http://www.bluecape.com.pt *\ | Based on Windows porting (1.5.x v3) by Symscape: http://www.symscape.com/ | \*---------------------------------------------------------------------------*/ Build : 1.6-f802ff2d6c5a Exec : C:\Program Files\blueCFD\ofuser-1.6\applications\bin\linuxmingw-w32DP Opt\parallelTest.exe -parallel Date : Oct 23 2009 Time : 16:21:16 Host : THE_MACHINE PID : 712 Case : C:/Program Files/blueCFD/ofuser-1.6/pTestCase nProcs : 2 Slaves : 1 ( THE_MACHINE.5024 ) Pstream initialized with: floatTransfer : 0 nProcsSimpleSum : 0 commsType : nonBlocking // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // Create time  Starting transfers   slave sending to master 0  slave receiving from master 0  Starting transfers   master receiving from slave 1  (0 1 2)  master sending to slave 1 End  (0 1 2) Finalising parallel run
4 Miscellaneous information
4.1 Differences between mingw32 and mingw-w32 versions
Mingw-w64 began as a spin-off from the mingw.org project, with the original intent of building for 64-bit targets.
Nonetheless, mingw-w64 has retro-compatibility with the 32bit MinGW version, thus enabling a 2-in-1 build package for 32 and 64bit Windows systems.
The main difference between mingw32 and mingw-w32, is that MinGW is a stable and proven build tool and run-time for Windows, while the mingw-w64 project is still under fierce development and only in October 29th of 2010 they released their first stable version. Therefore, it is only estimated that the mingw32 version could provide less headaches than mingw-w32.
4.2 Using Cygwin for cross-compiling OpenFOAM
For cross-compiling in Cygwin for Windows, see the page Using Cygwin for cross-compiling OpenFOAM.
5 Other Important Links
This is a list of links of build instructions of cross-compiled and natively compiled versions of OpenFOAM, using mingw and/or mingw-w64:
- Symscape's cross-compilations:
- Julian's OpenFOAM 1.5 files for native build in Windows  with mingw32 and CodeBlocks (instructions included inside files)
- blueCAPE's cross-compilations:
- Tonoda Kojani's blog (in Japanese) is having semi-regular changes and there are instructions for OpenFOAM source code version for building directly in Windows, without the need for Cygwin. At the time of this edit (17:06, 4 December 2010 (CET)), it wasn't possible to state which version is available, because of the semi-regular changes.
- Free: Julian's OpenFOAM for MS windows binary release - OpenFOAM 1.5 built natively in Windows  using mingw32 and CodeBlocks (note: development seems to have been dropped)
- Free: On Yuu Kasuga's blog (in Japanese) is a short tutorial on how to install and use the unofficial openfoam16wi32 project at SourceForge, which provides OpenFOAM 1.6 32bit binaries for Windows.
- Paid: Symscape's OpenFlow: OpenFOAM for Windows 
- Paid: blueCAPE's blueCFD: OpenFOAM for Windows XP, Vista and 7, both 32 and 64bit 
- Unknown status: Fraunhofer SCAI project - Porting Open Source HPC Software to Microsoft Windows Platforms  - availability is unknown, but a contact page exists 
Benchmarks and run-times running OpenFOAM cross-compiled with mingw:
- icoDyMFoam (movingCone) OpenFOAM tutorial 
- Xoodles pitzDaily3D OpenFOAM tutorial 
- simpleFoam motorBike OpenFOAM tutorial from 1.6.x, running with OpenFOAM 1.6 
- simpleFoam motorBike OpenFOAM tutorial from 1.6.x, running with OpenFOAM 1.6 in Linux and 1.7.0 in Windows 
Tutorials known to work with cross-compiled versions of OpenFOAM:
Threads at CFD-Online Forum for OpenFOAM, for discussing and questions about this page:
- Announcement of this page 
- Announcement of the patches for the 1.7 version 
- Support for this page is available here.
Wyldckat 15:13, 1 September 2010 (CEST) - Updated the "Important Links" section.
Wyldckat 15:46, 22 July 2010 (UTC) - Changes complete to this wiki page. Still have to create the page for the 1.7 version...
Wyldckat 11:31, 22 July 2010 (UTC) - Changes have begun to be made to this wiki page to incorporate the patches for OpenFOAM 1.7. Most of the content has branched into separate pages.
Wyldckat 14:34, 18 February 2010 (UTC) - Glitches were found in build-mingw32, and the fix is now provided inline with the tutorial. A bit later, a thread has been added to give support to this page.
Wyldckat 20:25, 19 January 2010 (UTC) - Updates to patches and wiki page:
- fixes made based on Symscape's version v9 for 1.6.x, because many of the solvers that use LES and RAS turbulence models need their libraries to be forced to load under Windows.
- chtMultiRegionFoam now works, with KK instead of K for Windows builds.
- Instructions on how to get OpenFOAM 1.6.x directly from repository using git under cygwin.
- reconstructParMesh wasn't being built because it wasn't in the respective Allwmake script.
- Linking OpenFOAM to MPICH2 no longer requires Wine to work straight out of the boxed up patch.
- Added link to tutorials that are known to work with these patches.
Wyldckat 22:20, 22 November 2009 (UTC) - Added information about cross-compiling in Cygwin
Wyldckat 01:41, 21 November 2009 (UTC) - Added thread link for discussion about this page
Wyldckat 18:20, 19 November 2009 (UTC) - Added info on cross-compiling with MPICH2, without Wine nor copying from Windows
Wyldckat 11:58, 18 November 2009 (UTC) - Added info about using CHOICE.EXE with DOS_Mode.bat
Wyldckat 18:21, 11 November 2009 (UTC) - First version of this step by step wiki page