OpenFOAM® Build Guide

OpenFOAM®  Build Guide

In the following sections, text in boxes should be entered into your shell window.

Ensure that the system requirements are satisfied as described here, and make sure to source the correct OpenFOAM environment e.g. for version OpenFOAM-v1912

source ~/OpenFOAM/OpenFOAM-v1912/etc/bashrc


A new build guide for third party libraries can be found in $WM_PROJECT_DIR/

Several build issues related to specific compiler and VTK library versions can be found in $WM_PROJECT_DIR/BuildIssues.txt


OpenFOAM is shipped with ParaView for post-processing OpenFOAM field results. This requires a separate compilation which can be omitted if using other post-processing software. To compile ParaView:



For most systems, CGAL is not normally installed or is likely to be an older version. We therefore recommend using CGAL from the ThirdParty source pack. This corresponds to the shipped settings in the etc/ file



In most cases, the system boost libraries can be used for OpenFOAM and for building CGAL. This corresponds to the shipped settings in the etc/ file


If, however, the system boost libraries are either not installed, too old, or are missing some components e.g. threaded support, it is recommended to switch to using boost from the ThirdParty source pack.


Combining a ThirdParty boost with a system CGAL is neither supported by the OpenFOAM build process, nor is it recommended.

Compile OpenFOAM

The compilation process is self-contained and will compile and install all OpenFOAM code and dependencies.

  • Test the system readiness

  • Change to the main OpenFOAM directory ($WM_PROJECT_DIR). If this fails, the environment is not configured correctly

  • Compile OpenFOAM

  • In case you need to stop the compilation, continue later by running Allwmake again

Compile OpenFOAM faster

For faster compilation, users can take advantage of multi-processor machines to build the code in parallel by setting the environment variable WM_NCOMPPROCS, e.g.

In addition, multiple machines can be used by setting:

export WM_SCHEDULER=wmakeScheduler
export WM_HOSTS="box1:4 box2:8"
  • WM_SCHEDULER - flag to use the scheduler
  • WM_HOSTS - names of hosts and number of their CPUs to use
  • WM_NCOMPPROCS - number of parallel processes

Note that the wmakeScheduler requires the lockfile utility. This can be installed using, e.g. on Ubuntu:

sudo apt install procmail

Post-compilation steps

  • Open a new shell and source the OpenFOAM environment to see all changes (refer to top of page)
  • Validate the build by running

  • Create the user run directory:

    mkdir -p $FOAM_RUN
  • Test the installation with a simple tutorial:

    cp -r $FOAM_TUTORIALS/incompressible/simpleFoam/pitzDaily ./
    cd pitzDaily