Difference between revisions of "Installation/Windows/Outdated/Cross Compiling OpenFOAM 1.7 in Linux For Windows with MinGW"

From OpenFOAMWiki
(Tweaking environment options)
(Tweaking environment options)
Line 99: Line 99:
 
:'''mingw-w32''': for getting a 32bit version of OpenFOAM, using gcc + mingw-w64;
 
:'''mingw-w32''': for getting a 32bit version of OpenFOAM, using gcc + mingw-w64;
 
:'''mingw-w64''': for getting a 64bit version of OpenFOAM, using gcc + mingw-w64;
 
:'''mingw-w64''': for getting a 64bit version of OpenFOAM, using gcc + mingw-w64;
*Using Ubuntu's 10.04 builds of mingw-w64: ([[User:Wyldckat|Wyldckat]] 17:26, 2 August 2010 (UTC) [[User:Wyldckat|Wyldckat]] unknown at this time if other distributions use the same nomenclature)
+
*Using Ubuntu's 10.04 builds of mingw-w64: ([[User:Wyldckat|Wyldckat]] 17:26, 2 August 2010 (UTC) - unknown at this time if other distributions use the same nomenclature)
 
:'''i586-mingw32msvc''': for getting a 32bit version of OpenFOAM, using system's gcc + mingw-w64;
 
:'''i586-mingw32msvc''': for getting a 32bit version of OpenFOAM, using system's gcc + mingw-w64;
 
:'''amd64-mingw32msvc''': for getting a 64bit version of OpenFOAM, using system's gcc + mingw-w64;
 
:'''amd64-mingw32msvc''': for getting a 64bit version of OpenFOAM, using system's gcc + mingw-w64;
*Builds available at mingw-w64's sourceforge.net project page:
+
*Using builds available at mingw-w64's sourceforge.net project page [http://sourceforge.net/projects/mingw-w64/]:
 
:'''i686-w64-mingw32''': for getting a 32bit version of OpenFOAM, using the <u>latest</u> pre-built gcc + mingw-w64;
 
:'''i686-w64-mingw32''': for getting a 32bit version of OpenFOAM, using the <u>latest</u> pre-built gcc + mingw-w64;
 
:'''x86_64-w64-mingw32''': for getting a 64bit version of OpenFOAM, using the <u>latest</u> pre-built gcc + mingw-w64;
 
:'''x86_64-w64-mingw32''': for getting a 64bit version of OpenFOAM, using the <u>latest</u> pre-built gcc + mingw-w64;
  
 
+
<br>
 
Variants of the "bashrc" file that is inside the folder '''$HOME/OpenFOAM/OpenFOAM-1.7.0/etc''', have been created, to meet the most likely options. These are:
 
Variants of the "bashrc" file that is inside the folder '''$HOME/OpenFOAM/OpenFOAM-1.7.0/etc''', have been created, to meet the most likely options. These are:
 
:;sample - <bashrc-version> : configured for <compiler>, <mingw version>, <MPI option>, <WM_COMPILE_OPTION>, <WM_ARCH_OPTION>
 
:;sample - <bashrc-version> : configured for <compiler>, <mingw version>, <MPI option>, <WM_COMPILE_OPTION>, <WM_ARCH_OPTION>
Line 119: Line 119:
 
:;bashrc-i586-mingw32msvcS : configured for gcc-4.4.2, mingw-w32, MPI with MPICH2, Opt, SP, 32
 
:;bashrc-i586-mingw32msvcS : configured for gcc-4.4.2, mingw-w32, MPI with MPICH2, Opt, SP, 32
 
:;bashrc-amd64-mingw32msvc : configured for gcc-4.4.2, mingw-w64, MPI with MPICH2, Opt, DP, 64
 
:;bashrc-amd64-mingw32msvc : configured for gcc-4.4.2, mingw-w64, MPI with MPICH2, Opt, DP, 64
:NOTE: for this last one, you will possibly need to install the mingw-w64 version for Ubuntu 10.04 available [https://launchpad.net/~pali.rohar/+archive/ppa by Pali here], because Ubuntu's initial version doesn't have the compiler '''amd64-mingw32msvc-g++'''.
+
:NOTE: for this last one above, you will possibly need to install the mingw-w64 version for Ubuntu 10.04 available [https://launchpad.net/~pali.rohar/+archive/ppa by Pali here], because Ubuntu's initial version doesn't have the compiler '''amd64-mingw32msvc-g++'''.
'''NOTE''': the following 3 versions were tested, both 32 and 64 bit versions work in Windows Vista/7 x64, but seemed somewhat unstable in some tutorials:
+
'''NOTE''': the following 3 versions were tested, both 32 and 64 bit versions work in Windows Vista/7 x64, but were unstable in some tutorials:
 
:;bashrc-i686-w64-mingw32 : configured for gcc-4.5.1 (or more recent), mingw-w32, MPI with MPICH2, Opt, DP, 32
 
:;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-i686-w64-mingw32S : configured for gcc-4.5.1 (or more recent), mingw-w32, MPI with MPICH2, Opt, SP, 32

Revision as of 17:30, 2 August 2010

NOTE: This page is still Under Construction...

The patches will only be released when they are ready and when this page is completed!



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

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:

OF version 17.png

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

  1. In your Linux machine, open a terminal window (example) and create the folder $HOME/OpenFOAM:
    mkdir $HOME/OpenFOAM
    cd $HOME/OpenFOAM
  2. 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
  3. 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

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: w3m flex git-core build-essential binutils-dev 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 building the code documentation are: doxygen graphviz texlive-latex-base qt4-dev-tools.

4 Applying patches

  1. Copy/move the PatchesNBatches17.tar.gz file into the $HOME/OpenFOAM folder. Then unpack it by running:
    tar -xzf PatchesNBatches17.tar.gz
  2. 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
  3. 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/bin/fixPatchExeNames
    chmod 744 $HOME/OpenFOAM/OpenFOAM-1.7.0/tutorials/Allwmake
    chmod 744 $HOME/OpenFOAM/OpenFOAM-1.7.0/multiBuilder
    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-mingw
    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

With these patches there is only one way to compile OpenFOAM with MPICH2, and it's done automatically by the script Allwmake.

So this chapter is only relevant in case you want to update the headers and definition files from 1.2.1p1 to another MPICH2 version:

  1. Download and install in Windows the MPICH2, any other version than 1.2.1p1 from here. Install both 32 and 64bit versions, if you wish to build OpenFOAM for both architectures.
  2. You will also have to download the source code package from that page.
  3. Create the folder $HOME/OpenFOAM/ThirdParty-1.7.0/mpich2-version/source/arch/include in your Linux set up (example and depending on the architectures you may want):
    mkdir -p $HOME/OpenFOAM/ThirdParty-1.7.0/mpich2-1.2.1p1/source/i686/include
    mkdir -p $HOME/OpenFOAM/ThirdParty-1.7.0/mpich2-1.2.1p1/source/x86_64/include
  4. From the installed MPICH2 in Windows, you will need to copy the following files from the include folder: mpi.h mpio.h mpicxx.h. And copy those files to the folder $HOME/OpenFOAM/ThirdParty-1.7.0/mpich2-version/source/arch/include.
  5. Then copy the files mpi.def mpich2.def from the source code package into the folder $HOME/OpenFOAM/ThirdParty-1.7.0/mpich2-version/source.
  6. Now to use a version of MPICH2 other than 1.2.1p1, then edit the file $HOME/OpenFOAM/OpenFOAM-1.7.1/etc/settings.sh and find the line that has mpi_version=mpich2-1.2.1p1 and change to the version you want, as shown here.

The Allwmake script at the folder ThirdParty-1.7.0 will take care of the rest.

6 Tweaking environment options

  1. Choose which version you want to use:
    • Custom builds:
    mingw32: for getting a 32bit version of OpenFOAM, using gcc + mingw;
    mingw-w32: for getting a 32bit version of OpenFOAM, using gcc + mingw-w64;
    mingw-w64: for getting a 64bit version of OpenFOAM, using gcc + mingw-w64;
    • Using Ubuntu's 10.04 builds of mingw-w64: (Wyldckat 17:26, 2 August 2010 (UTC) - unknown at this time if other distributions use the same nomenclature)
    i586-mingw32msvc: for getting a 32bit version of OpenFOAM, using system's gcc + mingw-w64;
    amd64-mingw32msvc: for getting a 64bit version of OpenFOAM, using system's gcc + mingw-w64;
    • Using builds available at mingw-w64's sourceforge.net project page [1]:
    i686-w64-mingw32: for getting a 32bit version of OpenFOAM, using the latest pre-built gcc + mingw-w64;
    x86_64-w64-mingw32: for getting a 64bit version of OpenFOAM, using the latest pre-built gcc + mingw-w64;

    Variants of the "bashrc" file that is inside the folder $HOME/OpenFOAM/OpenFOAM-1.7.0/etc, have been created, to meet the most likely options. These are:
    sample - <bashrc-version> 
    configured for <compiler>, <mingw version>, <MPI option>, <WM_COMPILE_OPTION>, <WM_ARCH_OPTION>
    bashrc-mingw32 
    configured for custom gcc, mingw32, MPI with MPICH2, Opt, DP, 32
    bashrc-mingw-w32 
    configured for custom gcc, mingw-w32, MPI with MPICH2, Opt, DP, 32
    bashrc-mingw-w32-prof 
    configured for custom gcc, mingw-w32, No MPI, Prof, DP, 32 (untested)
    bashrc-mingw-w32S 
    configured for custom gcc, mingw-w32, MPI with MPICH2, Opt, SP, 32
    bashrc-mingw-w64 
    configured for custom gcc, mingw-w64, MPI with MPICH2, Opt, DP, 64
    bashrc-mingw-w64-prof 
    configured for custom gcc, mingw-w64, No MPI, Prof, DP, 64 (untested)
    NOTE: the following 3 versions were tested but the 64bit version didn't work in Windows Vista/7 x64:
    bashrc-i586-mingw32msvc 
    configured for gcc-4.4.2, mingw-w32, MPI with MPICH2, Opt, DP, 32
    bashrc-i586-mingw32msvcS 
    configured for gcc-4.4.2, mingw-w32, MPI with MPICH2, Opt, SP, 32
    bashrc-amd64-mingw32msvc 
    configured for gcc-4.4.2, mingw-w64, MPI with MPICH2, Opt, DP, 64
    NOTE: for this last one above, you will possibly need to install the mingw-w64 version for Ubuntu 10.04 available by Pali here, because Ubuntu's initial version doesn't have the compiler amd64-mingw32msvc-g++.
    NOTE: the following 3 versions were tested, both 32 and 64 bit versions work in Windows Vista/7 x64, but were unstable in some tutorials:
    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
  2. 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-i686-w64-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 one or more of these:

    alias of170-mingw32='. $HOME/OpenFOAM/OpenFOAM-1.7.0/etc/bashrc-mingw32'
    alias of170-mingw-w32S='. $HOME/OpenFOAM/OpenFOAM-1.7.0/etc/bashrc-mingw-w32S'
    alias of170-mingw-w32D='. $HOME/OpenFOAM/OpenFOAM-1.7.0/etc/bashrc-mingw-w32'
    alias of170-mingw-w64='. $HOME/OpenFOAM/OpenFOAM-1.7.0/etc/bashrc-mingw-w64'
    alias of170-i586Dsys='. $HOME/OpenFOAM/OpenFOAM-1.7.0/etc/bashrc-i586-mingw32msvc'
    alias of170-i586Ssys='. $HOME/OpenFOAM/OpenFOAM-1.7.0/etc/bashrc-i586-mingw32msvcS'
    alias of170-x64sys='. $HOME/OpenFOAM/OpenFOAM-1.7.0/etc/amd64-mingw32msvc'
    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-x86_64-w64-mingw32'
    alias of170-linux='export WM_ARCH_OPTION=32; . $HOME/OpenFOAM/OpenFOAM-1.7.0/etc/bashrc'
    alias of170-linux64='. $HOME/OpenFOAM/OpenFOAM-1.7.0/etc/bashrc'
    Now, whenever you start a new terminal, run one of the alias commands; for example:
    of170-i686Dmingw

    NOTE: Feel free to change the alias names to something more short and to your liking!

7 Build the cross compiler

In this version of patches for OpenFOAM 1.7.0, the legacy build scripts from the patches for OpenFOAM 1.6.0 are still accessible, but they haven't been tested on this version. So, for those build scripts, see the page for the previous patches: Cross Compiling OpenFOAM 1.6 in Linux For Windows with MinGW - chapter Build the cross compiler

As for this version, you simply have to run the script getMinGWBin available in the folder ThirdParty-1.7.0:

cd $WM_THIRD_PARTY_DIR
./getMinGWBin

This script will search for the latest available pre-built version of the mingw-w64 compiler defined by the bashrc-compiler script for you Linux machine, whether it's i?86 or x86_64! It should also work in Cygwin.

NOTE: this script needs the application w3m, a text based browser, to be installed.

8 Cross-Compile OpenFOAM in Linux for Windows

  1. Open a new terminal window or tab, so it will reset environment variables and add the newly built cross-compiling gcc into the executable path variable (see Tweaking environment options). Go to the project folder as so:
    cd $WM_PROJECT_DIR
  2. Go to the folder "OpenFOAM-1.6" and run "Allwmake":
    ./Allwmake
    This will build the entire OpenFOAM package. This does not include: Paraview, OpenMPI and code documentation.
  3. Optional - If you want to build the code documentation, after OpenFOAM is built, run:
    wmake all doc

    This is only needs to be built once, since it's the same for all architectures.

    In the chapter Creating a compact help file for the code documentation is explained how to finish this step.

  4. Optional - If you want to be able to run the tutorial cases that need custom applications to be built, run:
    wmake all tutorials

    The applications will be cross-compiled and put in the folder $HOME/OpenFOAM/$USER-1.7.0/application/bin/$WM_OPTIONS, or $FOAM_USER_APPBIN for short.

  5. Building the mesh conversion utility ccm26ToFoam is now done automatically, when compared with the previous patch versions.
  6. For testing MPICH2, as described in this page's parent page, chapter Using MPICH2 with OpenFOAM in Windows, the parallel test application will be built automatically. The built executable will be placed in the folder $HOME/OpenFOAM/$USER-1.7.0/application/bin/$WM_OPTIONS, or $FOAM_USER_APPBIN for short.

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 22:39, 31 July 2010 (UTC) - Page development has stalled due to technical difficulties with existing pre-built mingw-w64 cross-compilers.

Wyldckat 15:48, 22 July 2010 (UTC) - Page created... content will be inserted periodically over the next hours...