|
|
|
<!-- --- title: Building from source -->
|
|
|
|
|
|
|
|
[](/home)
|
|
|
|
[](/precompiled)
|
|
|
|
|
|
|
|
[[_TOC_]]
|
|
|
|
|
|
|
|
##  Linux, Unix-like systems
|
|
|
|
|
|
|
|
|Version | Build |
|
|
|
|
|--------|--------|
|
|
|
|
|v2006 | [Build][latest-build] |
|
|
|
|
|v1912 | [Build][v1912-build] |
|
|
|
|
|v1906 | [Build][v1906-build] |
|
|
|
|
|older | _obsolete_ |
|
|
|
|
|
|
|
|
|
|
|
|
## Packaging systems
|
|
|
|
<a name="packaging"></a>
|
|
|
|
|
|
|
|
|System | Links | Status | Notes |
|
|
|
|
|---------------|--------------|----------------|---------------|
|
|
|
|
| [spack](https://spack.readthedocs.io/) | package [openfoam](https://github.com/spack/spack/tree/develop/var/spack/repos/builtin/packages/openfoam/) | Actively maintained by OpenCFD | [notes](#spack) |
|
|
|
|
| [EasyBuild](https://easybuild.readthedocs.io/) | package [OpenFOAM](https://github.com/easybuilders/easybuild-easyconfigs/tree/master/easybuild/easyconfigs/o/OpenFOAM) | Maintained independently, with input from OpenCFD | |
|
|
|
|
| debian, RPM | _See [precompiled](/precompiled)_ | Actively maintained by OpenCFD | |
|
|
|
|
|
|
|
|
|
|
|
|
### spack
|
|
|
|
<a name="spack"></a>
|
|
|
|
|
|
|
|
The installation of openfoam with spack will generally require the
|
|
|
|
latest (development version) of spack. If this is available, you can
|
|
|
|
install openfoam in various configurations and dependencies, but
|
|
|
|
typically can simply install directly:
|
|
|
|
|
|
|
|
```
|
|
|
|
$ spack install openfoam
|
|
|
|
```
|
|
|
|
|
|
|
|
##  Darwin (Mac-OS)
|
|
|
|
|
|
|
|
The support for Darwin is complete, but less well tested than Linux.
|
|
|
|
|
|
|
|
- The Darwin build (and operation) requires a **case-sensitive file system**,
|
|
|
|
which is often created as a disk image and mounted (for older systems).
|
|
|
|
- Compilation uses the system clang compiler.
|
|
|
|
|
|
|
|
|
|
|
|
### Known issues
|
|
|
|
|
|
|
|
CGAL
|
|
|
|
- ThirdParty CGAL will normally need to be compiled _without_ mpfr/gmp.
|
|
|
|
This should be done manually prior to building OpenFOAM or other
|
|
|
|
ThirdParty. Eg,
|
|
|
|
```
|
|
|
|
cd $WM_THIRD_PARTY_DIR
|
|
|
|
./makeCGAL gmp-none mpfr-none
|
|
|
|
```
|
|
|
|
The `wmake/rules/darwin64Clang/CGAL` file has been adjusted to
|
|
|
|
eliminate references to gmp/mpfr libraries.
|
|
|
|
|
|
|
|
|
|
|
|
##  Windows (cross-compiled)
|
|
|
|
|
|
|
|
Windows 64bit binaries can be generated on 64bit Linux by
|
|
|
|
***[cross-compilation](/building/cross-compile-mingw)***.
|
|
|
|
|
|
|
|
|
|
|
|
##  Tuning
|
|
|
|
|
|
|
|
### Different compiler versions
|
|
|
|
<a name="different-compiler-versions"></a>
|
|
|
|
|
|
|
|
By default, OpenFOAM handles newer/older non-system compilers as
|
|
|
|
_ThirdParty_ installations and uses the combination of `WM_COMPILER`
|
|
|
|
and `WM_COMPILER_TYPE` to select them. In some cases, however, it can
|
|
|
|
be much more convenient for the user to install prebuilt compiler
|
|
|
|
binaries as *system* compilers (eg, using deb or rpm packages).
|
|
|
|
This poses a slight problem since the OpenFOAM build rules normally
|
|
|
|
use the main compiler name (`gcc`, `clang` etc) without any additional
|
|
|
|
version information, but the various *system* compilers are frequently
|
|
|
|
installed with versioned names such as `gcc-8`, `clang-10` etc.
|
|
|
|
|
|
|
|
Here is a simple way to solve this, using clang-10 on openSUSE for the
|
|
|
|
example:
|
|
|
|
|
|
|
|
1. Install the desired system compiler.
|
|
|
|
In this case [clang-10 from tools:compiler][llvm10-opensuse] which
|
|
|
|
installs `/usr/bin/clang-10` and `/usr/bin/clang++-10`.
|
|
|
|
|
|
|
|
2. Next override the OpenFOAM compiler calls, but without blindly
|
|
|
|
rewriting everything.
|
|
|
|
|
|
|
|
We create a new directory for our special rules:
|
|
|
|
```
|
|
|
|
mkdir wmake/rules/linux64Clang100
|
|
|
|
```
|
|
|
|
Inside this directory, we add an general rules file
|
|
|
|
(`wmake/rules/linux64Clang100/general`) with the following contents:
|
|
|
|
```
|
|
|
|
# Override compiler calls for llvm-10
|
|
|
|
|
|
|
|
cc = clang-10
|
|
|
|
CC = clang++-10 -std=c++11
|
|
|
|
```
|
|
|
|
Or if this shall be restricted to system compilers only:
|
|
|
|
```
|
|
|
|
# Override system compiler calls for llvm-10
|
|
|
|
ifeq (system,$(WM_COMPILER_TYPE))
|
|
|
|
cc = clang-10
|
|
|
|
CC = clang++-10 -std=c++11
|
|
|
|
endif
|
|
|
|
```
|
|
|
|
|
|
|
|
3. The final step is to select this compiler definition with the following
|
|
|
|
combination:
|
|
|
|
```
|
|
|
|
# Preferences for system Clang100
|
|
|
|
|
|
|
|
export WM_COMPILER=Clang100
|
|
|
|
export WM_COMPILER_TYPE=system
|
|
|
|
```
|
|
|
|
|
|
|
|
If this change represents your standard default compiler definition,
|
|
|
|
then place the information into the `etc/prefs.sh` file (see the
|
|
|
|
`etc/bashrc` file for some details) and re-source your OpenFOAM
|
|
|
|
environment.
|
|
|
|
|
|
|
|
If you would like to selectively enable this compiler definition, a
|
|
|
|
common means is to place the same definition information into a user
|
|
|
|
configuration file (for example, `~/.OpenFOAM/clang100`) and then
|
|
|
|
specify that configuration when sourcing your OpenFOAM environment.
|
|
|
|
For example,
|
|
|
|
```
|
|
|
|
source /path/to/OpenFOAM-version/etc/bashrc clang100
|
|
|
|
```
|
|
|
|
|
|
|
|
The `bashrc` will locate and use the configuration file, after which the
|
|
|
|
compiler will be properly selected. To verify that this is indeed the
|
|
|
|
case:
|
|
|
|
```
|
|
|
|
wmake -show-cxx
|
|
|
|
```
|
|
|
|
should display the selected compiler.
|
|
|
|
You may also wish to verify its path:
|
|
|
|
```
|
|
|
|
wmake -show-path-cxx
|
|
|
|
```
|
|
|
|
For older versions, `which $(wmake -show-cxx)` instead.
|
|
|
|
|
|
|
|
--------
|
|
|
|
|
|
|
|
[latest-build]: https://develop.openfoam.com/Development/openfoam/blob/develop/doc/Build.md
|
|
|
|
|
|
|
|
[v2006-build]: https://develop.openfoam.com/Development/openfoam/blob/maintenance-v2006/doc/Build.md
|
|
|
|
[v1912-build]: https://develop.openfoam.com/Development/openfoam/blob/maintenance-v1912/doc/Build.md
|
|
|
|
[v1906-build]: https://develop.openfoam.com/Development/openfoam/blob/maintenance-v1906/doc/Build.md
|
|
|
|
[v1906-notes]: https://www.openfoam.com/releases/openfoam-v1906/
|
|
|
|
|
|
|
|
[llvm10-opensuse]: https://software.opensuse.org//download.html?project=devel%3Atools%3Acompiler&package=llvm10 |