... | ... | @@ -4,115 +4,110 @@ |
|
|
[![build](/icons/cpu.svg "build")](/building)
|
|
|
[![packages](/icons/package.svg "packages")](/precompiled)
|
|
|
|
|
|
[[_TOC_]]
|
|
|
|
|
|
![windows](/icons/microsoft.svg "windows")
|
|
|
|
|
|
Windows 64bit binaries can be generated on 64bit Linux using
|
|
|
the [mingw](http://mingw.org/) compiler for _cross-compilation_.
|
|
|
|
|
|
- The mingw cross-compiler should be at least version 8.2.0 (tested),
|
|
|
but could be _slightly_ older. Versions that are much older likely
|
|
|
have faulty regex implementations.
|
|
|
|
|
|
## Minimum version
|
|
|
|
|
|
The mingw cross-compiler should be at least version 8.2.0 (tested) or
|
|
|
slightly older. Versions that are much older may have faulty regex
|
|
|
implementations.
|
|
|
[[_TOC_]]
|
|
|
|
|
|
## Host setup
|
|
|
|
|
|
### For openSUSE
|
|
|
### ![>>](/icons/opensuse.svg) openSUSE
|
|
|
|
|
|
On openSUSE use the packages for compilation:
|
|
|
On openSUSE use these packages for compilation:
|
|
|
```
|
|
|
zypper in mingw64-cross-binutils
|
|
|
zypper in mingw64-cross-cpp mingw64-cross-gcc mingw64-cross-gcc-c++
|
|
|
zypper in mingw64-filesystem mingw64-headers mingw64-runtime
|
|
|
|
|
|
zypper in mingw64-libwinpthread1 mingw64-winpthreads-devel
|
|
|
zypper in mingw64-libfftw3 mingw64-fftw3-devel
|
|
|
zypper in mingw64-libz mingw64-zlib-devel
|
|
|
|
|
|
# Note: can cross-compile FFTW from ThirdParty sources instead
|
|
|
zypper in mingw64-libfftw3 mingw64-fftw3-devel
|
|
|
```
|
|
|
|
|
|
### For CentOS/RedHat
|
|
|
|
|
|
For CentOS/RedHat, the cross-compiler is available under `PowerTools`:
|
|
|
### ![>](/icons/centos.svg)![>](/icons/redhat.svg) CentOS/RedHat
|
|
|
|
|
|
For CentOS/RedHat, the cross-compiler is available under _PowerTools_
|
|
|
```
|
|
|
dnf config-manager --set-enabled PowerTools
|
|
|
```
|
|
|
|
|
|
The package names to install are _somewhat_ different from the openSUSE
|
|
|
ones:
|
|
|
The packages have slightly different names than the openSUSE ones:
|
|
|
```
|
|
|
dnf install mingw64-gcc-c++
|
|
|
dnf install mingw64-winpthreads mingw64-zlib
|
|
|
```
|
|
|
|
|
|
Notably, many of the development packages are simply rolled into the
|
|
|
runtime ones. There does not seem to be an FFTW package readily
|
|
|
available.
|
|
|
runtime ones. An FFTW package appears to be missing, but cross-compiling
|
|
|
one from ThirdParty sources makes reasonable sense anyhow.
|
|
|
|
|
|
***Caution***
|
|
|
> Cross-compiling on RedHat systems has not always be successful
|
|
|
> in the past. The runtime packages often lag behind the windows runtime
|
|
|
> environment and the cross-compiling packages simply do not run.
|
|
|
|
|
|
|
|
|
### General
|
|
|
|
|
|
If there are issues with zlib, it is possible to download it manually
|
|
|
and compile as a _static_ library.
|
|
|
Since the settings for cross-compilation will often differ from the
|
|
|
native compilation, it is advisable to isolate the changes in a
|
|
|
dedicated directory (OpenFOAM-v2006 and later).
|
|
|
We normally create a `etc-mingw` directory as a convenient reminder to
|
|
|
its purpose.
|
|
|
|
|
|
The overall preferences (etc-mingw/prefs.sh):
|
|
|
```
|
|
|
CC="$(wmake -show-c)" CFLAGS="$(wmake -show-cflags)" ./configure --static
|
|
|
make
|
|
|
```
|
|
|
# Preferences for mingw cross-compiled
|
|
|
|
|
|
The resulting output files (zconf.h, zlib.h) and (libz.a) either need
|
|
|
to be installed in system locations where OpenFOAM can find them, or if
|
|
|
they are to be shipped directly with OpenFOAM, they can also be placed
|
|
|
in the `src/OpenFOAM/include` and `platforms/XXX/lib` paths.
|
|
|
export FOAM_CONFIG_ETC="etc-mingw"
|
|
|
export WM_COMPILER=Mingw
|
|
|
export WM_MPLIB=MSMPI
|
|
|
```
|
|
|
|
|
|
If the header files are only needed during compilation, it can be a
|
|
|
fairly convenient hack to simply place copies of them in the
|
|
|
`src/OSspecific/MSwindows` directory.
|
|
|
To disable CGAL (etc-mingw/config.sh/CGAL):
|
|
|
```
|
|
|
boost_version=boost-none
|
|
|
cgal_version=CGAL-none
|
|
|
|
|
|
Flex is used in a few locations within OpenFOAM for generating code.
|
|
|
The generated C++ code requires the `FlexLexer.h` header file, but
|
|
|
its `/usr/include` location will be ignored by the cross-compiler.
|
|
|
export BOOST_ARCH_PATH="/$boost_version"
|
|
|
export CGAL_ARCH_PATH="/$cgal_version"
|
|
|
```
|
|
|
|
|
|
As another ugly hack, a copy of this file can be made in a standard
|
|
|
project include location. For example,
|
|
|
For a system FFTW (etc-mingw/config.sh/FFTW):
|
|
|
```
|
|
|
ln -s /usr/include/FlexLexer.h src/OSspecific/MSwindows
|
|
|
fftw_version=fftw-system
|
|
|
export FFTW_ARCH_PATH=/usr/x86_64-w64-mingw32/sys-root/mingw
|
|
|
```
|
|
|
|
|
|
The last point to consider when cross-compiling is the behaviour of
|
|
|
the OpenFOAM wmake toolchain used during compilation. These are found
|
|
|
under `wmake/src`. If the `Makefile` is used directly, executables
|
|
|
will be created that work on the target platform (Windows), but *not*
|
|
|
on the host platform (which is what is required). This is addressed
|
|
|
directly by the `wmake/src/Allmake` script, which will use the system
|
|
|
gcc to create host binaries for the wmake toolchain. If, for some
|
|
|
reason, you also require target wmake toolchain binaries, you will
|
|
|
need to invoke `make` manually within the `wmake/src` directory.
|
|
|
|
|
|
Since we have created the `etc-mingw` directory in OpenFOAM project
|
|
|
directory, it is easiest to source the environment from there:
|
|
|
```
|
|
|
source etc/bashrc etc-mingw/prefs.sh
|
|
|
|
|
|
The settings for cross-compilation are normally defined in the
|
|
|
`etc/prefs.sh` file with contents like this:
|
|
|
# With additional verbosity of the sourcing
|
|
|
FOAM_VERBOSE=true source etc/bashrc etc-mingw/prefs.sh
|
|
|
```
|
|
|
# For mingw cross-compile
|
|
|
|
|
|
export WM_COMPILER=Mingw
|
|
|
export WM_MPLIB=MSMPI
|
|
|
|
|
|
export WM_LABEL_SIZE=32
|
|
|
# other settings...
|
|
|
```
|
|
|
### ![!!](/icons/alert-triangle.svg) Before a full compilation
|
|
|
|
|
|
Additional adjustments may be required in some other places. For example
|
|
|
in `etc/config.sh/FFTW`:
|
|
|
_Before_ spending a large amount of time and effort with cross-compiling
|
|
|
and installing, it is advisable to verify that the simplest possible
|
|
|
application works successfully on the target machine.
|
|
|
This small test application/library suite is called _Test-dummyLib_
|
|
|
and is located under
|
|
|
```
|
|
|
fftw_version=fftw-system
|
|
|
export FFTW_ARCH_PATH=/usr/x86_64-w64-mingw32/sys-root/mingw
|
|
|
applications/test/00-dummy/Allwmake
|
|
|
```
|
|
|
|
|
|
|
|
|
## Run-time setup
|
|
|
## ![win](/icons/microsoft.svg) Run-time setup
|
|
|
|
|
|
When running, the `WM_PROJECT_DIR` environment must be set.
|
|
|
OpenFOAM will otherwise not be able to locate its files.
|
... | ... | @@ -141,16 +136,53 @@ the entire directory contents: |
|
|
- `/usr/x86_64-w64-mingw32/sys-root/mingw/bin/*.dll`
|
|
|
|
|
|
|
|
|
## Known limitations (2020-06-16)
|
|
|
## Additional Notes / Workarounds
|
|
|
|
|
|
### Flex
|
|
|
|
|
|
Flex is used in a few locations within OpenFOAM for generating code.
|
|
|
The generated C++ code requires the `FlexLexer.h` header file, but its
|
|
|
`/usr/include` location will be ignored by the cross-compiler. As a
|
|
|
moderately ugly workaround, a copy of this file can be made in a
|
|
|
standard project include location as part of the compilation process.
|
|
|
For example,
|
|
|
```
|
|
|
ln -s /usr/include/FlexLexer.h src/OSspecific/MSwindows
|
|
|
```
|
|
|
|
|
|
### libz
|
|
|
|
|
|
If there are any issues with the system zlib, it is possible to
|
|
|
download it manually and compile it as a _static_ library.
|
|
|
```
|
|
|
CC="$(wmake -show-c)" CFLAGS="$(wmake -show-cflags)" ./configure --static
|
|
|
make
|
|
|
```
|
|
|
The resulting output files (zconf.h, zlib.h) and (libz.a) either need
|
|
|
to be installed in system locations where OpenFOAM can find them, or if
|
|
|
they are to be shipped directly with OpenFOAM, they can also be placed
|
|
|
in the `src/OpenFOAM/include` and `platforms/linux64Mingw*/lib`
|
|
|
paths.
|
|
|
|
|
|
If the header files are only needed during compilation, it can be a
|
|
|
fairly convenient hack to simply place copies of them in the
|
|
|
`src/OSspecific/MSwindows` directory.
|
|
|
|
|
|
|
|
|
### The wmake toolchain
|
|
|
|
|
|
***Always*** use the `wmake/src/Allmake` script (called automatically)
|
|
|
to ensure that the wmake binary toolchain is built for the _host_
|
|
|
platform where it is needed.
|
|
|
|
|
|
|
|
|
## Known limitations (2020-11-25)
|
|
|
|
|
|
- kahip does not build
|
|
|
- ptscotch does not build
|
|
|
- boost should build ok, but no CGAL support (ie, no foamyHexMesh)
|
|
|
- no ParaView plugin, runTimePostProcessing
|
|
|
- reacting EulerFoam solvers have too many interdependencies and do
|
|
|
not yet compile cleanly.
|
|
|
It is advisable to compile with the wmake `-k` option to keep going
|
|
|
even when the EulerFoam solvers fail to compile.
|
|
|
|
|
|
|
|
|
--------
|
|
|
|
... | ... | |