Installation/Windows/Outdated/Cross Compiling OpenFOAM 1.7 in Linux For Windows with MinGW
Under construction...
The parent page of this page is Tip Cross Compiling OpenFOAM in Linux For Windows with MinGW - please visit it for more information.
Contents
- 1 Introduction
- 2 Get OpenFOAM packages
- 3 Things needed for properly cross-compiling OpenFOAM 1.7.0
- 4 Applying patches
- 5 Getting Windows version of MPICH2 into the ThirdParty-1.7.0 folder in Linux
- 6 Tweaking environment options
- 7 Build the cross compiler
- 8 Cross-Compile OpenFOAM in Linux for Windows
- 9 Copying the files to your Windows installation
- 10 Creating a compact help file for the code documentation
- 11 Notes on what doesn't work and why
- 11.1 motorBike case and foamToVTK in Windows
- 11.2 libscotch is limited in Windows
- 11.3 Symbolic links in the tutorials
- 11.4 Open MPI in Windows
- 11.5 Cross-compiled version mingw-w64 takes longer to start applications
- 11.6 Some tutorials don't work in Windows
- 11.7 Tutorial scripts don't work in Windows
- 11.8 DOS_Mode.bat won't allow choosing which version to use
- 12 Notes on added functionalities with these patches
- 12.1 chtMultiRegionFoam and chtMultiRegionSimpleFoam slightly different in Windows
- 12.2 foamToVTK binary VTK files now functional in Windows
- 12.3 Building ccm26ToFoam
- 12.4 Keeping track of symbolic links in tutorials
- 12.5 Changes in settings.sh
- 12.6 Building locally with multiple cores
- 12.7 Building mingw cross-compilers
- 12.8 Getting MPICH2 automatically in Linux
- 12.9 Compiling HTML files into CHM and QCH/QHC
- 12.10 Creating new patches
- 12.11 Profiling OpenFOAM applications with mingw cross-compiled version
- 12.12 Backing up development folders
- 12.13 Smart library loading
- 13 History
1 Introduction
This is an exhaustive step by step guide on how to fully cross-compile OpenFOAM 1.7.0 in Linux for Windows, for both 32 and 64 bits architectures (from and to), using the patches available here. NOTE: for cross-compiling in Cygwin for Windows, see the section Using Cygwin for cross-compiling OpenFOAM.
These patches are a continuation of the ones for OpenFOAM 1.6.0 (see Cross Compiling OpenFOAM 1.6 in Linux For Windows with MinGW). These are now based on Symscape's "v11" patch for OpenFOAM 1.6.x available here. For a brief description on the differences between the patches on this page and the ones on Symscape's page, see the Introduction chapter page on the parent page.
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. Currently you can cross-compile using mingw-w64 for both 32 and 64 bit versions. These enable you to build OpenFOAM 1.7.0 for Windows 32 and 64 bit versions, from Linux 32 and 64bit architectures. See the chapter Notes on what doesn't work and why, for information on things that don't work properly. NOTE: The old build scripts from the 1.6 version are still available on these patches, although not tested yet, and should also allow you to build with mingw32. For more information about them, see the 1.6 patch version page, chapter Building the cross-compiler.
Versions these patches apply to:
Other versions and common information to all MinGW cross-compiled versions is available in the page Tip Cross Compiling OpenFOAM in Linux For Windows with MinGW.
Support for this page is available at OpenFOAM's forum here.
2 Get OpenFOAM packages
- In your Linux machine, open a terminal window (example) and create the folder $HOME/OpenFOAM:
mkdir $HOME/OpenFOAM cd $HOME/OpenFOAM
- Get OpenFOAM-1.7.0.gtgz and ThirdParty-1.7.0.gtgz from the OpenFOAM's sourceforge.net project page and copy/move them to the folder $HOME/OpenFOAM. If you want direct download from the terminal, then do:
wget http://downloads.sourceforge.net/foam/OpenFOAM-1.7.0.gtgz?use_mirror=mesh wget http://downloads.sourceforge.net/foam/ThirdParty-1.7.0.gtgz?use_mirror=mesh
- Extract both files, by running in a terminal:
tar xzf OpenFOAM-1.7.0.gtgz tar xzf ThirdParty-1.7.0.gtgz
3 Things needed for properly cross-compiling OpenFOAM 1.7.0
STILL HAVE TO FINISH UPDATING PACKAGES NAMES
The following packages should allow you to both build OpenFOAM for Linux and Windows:
- The packages needed in Linux (these are Ubuntu 10.04 package names) are: flex git-core build-essential binutils-dev python-dev libqt4-dev libreadline5-dev wget zlib1g-dev texinfo byacc bison.
- For the x86_64 Linux platform, you will also need: gcc-multilib
- The packages required for documentation are: doxygen graphviz.
4 Applying patches
- Copy/move the PatchesNBatches17.tar.gz file into the $HOME/OpenFOAM folder. Then unpack it by running:
tar -xzf PatchesNBatches17.tar.gz
- A new folder is created, named pnb17. Now to apply the patches, run from the $HOME/OpenFOAM folder:
patch -p0 < pnb17/OpenFOAM-1.7.0_patch patch -p0 < pnb17/ThirdParty-1.7.0_patch
- Still have to do some chmodding, for new scripts to run properly. Run the following lines in the terminal:
chmod 744 $HOME/OpenFOAM/OpenFOAM-1.7.0/src/Allclean chmod 744 $HOME/OpenFOAM/OpenFOAM-1.7.0/applications/utilities/parallelProcessing/Allwmake chmod 744 $HOME/OpenFOAM/OpenFOAM-1.7.0/bin/tutowin chmod 744 $HOME/OpenFOAM/OpenFOAM-1.7.0/bin/foamDiff chmod 744 $HOME/OpenFOAM/OpenFOAM-1.7.0/bin/backupSourceFolder chmod 744 $HOME/OpenFOAM/OpenFOAM-1.7.0/bin/backupFullFolder chmod 744 $HOME/OpenFOAM/OpenFOAM-1.7.0/bin/chtMultiRegionFixK chmod 744 $HOME/OpenFOAM/OpenFOAM-1.7.0/tutorials/Allwmake chmod 744 $HOME/OpenFOAM/ThirdParty-1.7.0/AllwcleanRegEx chmod 744 $HOME/OpenFOAM/ThirdParty-1.7.0/AllwcleanZLib chmod 744 $HOME/OpenFOAM/ThirdParty-1.7.0/AllwmakeMinGWScotch chmod 744 $HOME/OpenFOAM/ThirdParty-1.7.0/AllwmakeRegEx chmod 744 $HOME/OpenFOAM/ThirdParty-1.7.0/AllwmakeZLib chmod 744 $HOME/OpenFOAM/ThirdParty-1.7.0/build-mingw32 chmod 744 $HOME/OpenFOAM/ThirdParty-1.7.0/build-mingw-w32 chmod 744 $HOME/OpenFOAM/ThirdParty-1.7.0/build-mingw-w64 chmod 744 $HOME/OpenFOAM/ThirdParty-1.7.0/build-mingw-w64-45 chmod 744 $HOME/OpenFOAM/ThirdParty-1.7.0/fixSystemMingw chmod 744 $HOME/OpenFOAM/ThirdParty-1.7.0/genMPICH2stubs chmod 744 $HOME/OpenFOAM/ThirdParty-1.7.0/getMinGWBin chmod 744 $HOME/OpenFOAM/ThirdParty-1.7.0/makeGcc44
5 Getting Windows version of MPICH2 into the ThirdParty-1.7.0 folder in Linux
TODO: I still have to check how I did it... because I knwo things have changed quite a bit...
There are two ways of getting OpenFOAM to compile with MPICH2:
- Use the get-mpich2 script - the current patch has the include files and library definition files necessary to be able to link OpenFOAM to MPICH2. No need for changes, unless you want to build with a version of MPICH2 different from 1.2.1p1.
- Copy MPICH2 files from a Windows Installation. Three steps for this part:
- Download and install in Windows the MPICH2, version 1.2.1p1 Win32 IA32 from here. Also get and install the 64bit version, if you wish to build OpenFOAM for Windows x64.
- Create the folder $HOME/OpenFOAM/ThirdParty-1.7.0/mpich2-1.2.1p1 in your Linux set up:
mkdir $HOME/OpenFOAM/ThirdParty-1.7.0/mpich2-1.2.1p1
- Copy the folders bin, include and lib from the installed version of MPICH2 in Windows, into the folder ThirdParty-1.7.0/mpich2-1.2.1p1 in Linux.
- The Allwmake script at the folder ThirdParty-1.7.0 will take care of the rest. For now, the tough part is that, this way, you can only build one version of OpenFOAM (32 or 64bit) at a time.
In the next chapter, you will learn how to configure the variable that is responsible for these two choices.
6 Tweaking environment options
- Choose which version you want to use:
- mingw32: for getting a 32bit version of OpenFOAM, that builds on Linux i?86, using mingw (NOTE: untested in this patch version);
- mingw-w32: for getting a 32bit version of OpenFOAM, that builds on Linux i686 and x86_64, using mingw-w64;
- mingw-w64: for getting a 64bit version of OpenFOAM, that builds on Linux i686 and x86_64, using mingw-w64;
- sample - <bashrc-version>
- configured for <compiler>, <mingw version>, <MPI option>, <WM_COMPILE_OPTION>, <WM_ARCH_OPTION>
- bashrc-i686-w64-mingw32
- configured for gcc-4.5.1 (or more recent), mingw-w32, MPI with MPICH2, Opt, DP, 32
- bashrc-i686-w64-mingw32S
- configured for gcc-4.5.1 (or more recent), mingw-w32, MPI with MPICH2, Opt, SP, 32
- bashrc-x86_64-w64-mingw32
- configured for gcc-4.5.1 (or more recent), mingw-w64, MPI with MPICH2, Opt, DP, 64
- bashrc-mingw32
- configured for gcc-4.3.3, mingw32, MPI with MPICH2, Opt, DP, 32
- bashrc-mingw-w32
- configured for gcc-4.4.2, mingw-w32, MPI with MPICH2, Opt, DP, 32
- bashrc-mingw-w32-prof
- configured for gcc-4.4.2, mingw-w32, No MPI, Prof, DP, 32
- bashrc-mingw-w32S
- configured for gcc-4.4.2, mingw-w32, MPI with MPICH2, Opt, SP, 32
- bashrc-mingw-w64
- configured for gcc-4.4.2, mingw-w64, MPI with MPICH2, Opt, DP, 64
- bashrc-mingw-w64-prof
- configured for gcc-4.4.2, mingw-w64, No MPI, Prof, DP, 64
- bashrc-mingw-w64-45
- configured for gcc-4.5.0, mingw-w64, MPI with MPICH2, Opt, DP, 64
- After choosing the version you wish to build, edit the file $HOME/.bashrc and add to the end of it, a line analogous to the following line:
. $HOME/OpenFOAM/OpenFOAM-1.7.0/etc/bashrc-i686-w64-mingw32
WARNING: sometimes the leading dot doesn't work, so use the following instead:
source $HOME/OpenFOAM/OpenFOAM-1.7.0/etc/bashrc-mingw32
Optional: in case you want to have access to all versions without having to edit again the file $HOME/.bashrc, then instead of adding that line above, add these:
alias of170-i686Dmingw='. $HOME/OpenFOAM/OpenFOAM-1.7.0/etc/bashrc-i686-w64-mingw32' alias of170-i686Smingw='. $HOME/OpenFOAM/OpenFOAM-1.7.0/etc/bashrc-i686-w64-mingw32S' alias of170-x64mingw='. $HOME/OpenFOAM/OpenFOAM-1.7.0/etc/bashrc-i686-w64-mingw32' alias of170-linux='. $HOME/OpenFOAM/OpenFOAM-1.7.0/etc/bashrc'
Now, whenever you start a new terminal, start TODO... NOTE: Feel free to change the alias names to something more short an to your liking!
- Before launching a new terminal, edit the picked file $HOME/OpenFOAM/OpenFOAM-1.6/etc/bashrc-mingw version. You have two additional variables that are configurable and non standard to the original OpenFOAM version:
- WM_PSTREAMLINK - this variable allows control over the linking method that is with the Pstream library. Two options are available:
- If set to DONTLINKTOPSTREAM, then depending on the variable WM_MPLIB being set to NONE or MPICH, then OpenFOAM will be statically linked with that version; that means that it will only run without MPI capabilities or only run with MPICH2 installed, respectively.
- If LINKTOPSTREAM, then DLLs of the library Pstream are created, both dummy and MPICH2 versions; this allows you to choose which version to use in Windows, without rebuilding OpenFOAM again. This way you get 2 versions of OpenFOAM with just one build, which is useful for various installation environments.
- WM_GETMPICH2 - this variable controls whether MPICH2 is setup automatically or manually (see Getting Windows version of MPICH2 into the ThirdParty-1.6 folder in Linux). The two options are:
- If set to GETMPICH2, then wget is used for downloading the MPICH2 installation packages, and Wine will be used to unpack the ".msi" files.
- If DONTGETMPICH2, then the script will assume that MPICH2 was set up manually.
- WM_PSTREAMLINK - this variable allows control over the linking method that is with the Pstream library. Two options are available:
7 Build the cross compiler
TODO...
8 Cross-Compile OpenFOAM in Linux for Windows
TODO... NOTE: don't forget about the Allwmake script now available at the tutorials folder...
9 Copying the files to your Windows installation
TODO...
10 Creating a compact help file for the code documentation
TODO...
10.1 Creating a Compiled HTML (CHM) file for the code documentation
10.2 Creating a Qt QCH/QHC files for the code documentation
11 Notes on what doesn't work and why
TODO...
11.1 motorBike case and foamToVTK in Windows
11.2 libscotch is limited in Windows
11.3 Symbolic links in the tutorials
11.4 Open MPI in Windows
11.5 Cross-compiled version mingw-w64 takes longer to start applications
11.6 Some tutorials don't work in Windows
11.7 Tutorial scripts don't work in Windows
11.8 DOS_Mode.bat won't allow choosing which version to use
12 Notes on added functionalities with these patches
12.1 chtMultiRegionFoam and chtMultiRegionSimpleFoam slightly different in Windows
12.2 foamToVTK binary VTK files now functional in Windows
12.3 Building ccm26ToFoam
12.4 Keeping track of symbolic links in tutorials
12.5 Changes in settings.sh
12.6 Building locally with multiple cores
12.7 Building mingw cross-compilers
12.8 Getting MPICH2 automatically in Linux
12.9 Compiling HTML files into CHM and QCH/QHC
12.10 Creating new patches
12.11 Profiling OpenFOAM applications with mingw cross-compiled version
12.12 Backing up development folders
12.13 Smart library loading
13 History
Wyldckat 15:48, 22 July 2010 (UTC) - Page created... content will be inserted periodically over the next hours...