FAQ/Installation and Running

From OpenFOAMWiki


1 FAQ Section 2: Installation and Running

Problems with the installation and running of applications

1.1 How to install OpenFOAM and any of its variants?

These are the known installation instructions for OpenFOAM and many of its forks/variants:

  1. The instructions for the official OpenFOAM versions are provided at the OpenFOAM Foundation website.
  2. The instructions for the Extend variant foam-extend are provided at the Wikki website, in the page Download & Install.
  3. The instructions for installing FreeFOAM are provided at their official website: FreeFOAM Installation Instructions
  4. The instructions for installing Caelus-CML are provided at their official website: Caelus-CML Download
  5. Instructions written by the community are mostly centralized here at openfoamwiki.net, in the page Installation.
  6. Questions about installing any of these versions/variants can be asked at the (unofficial) forum at CFD-Online:

1.2 Which platforms are supported by OpenFOAM ?

Officially, only Linux Distributions are supported: OpenFOAM Repo: 1. Software for Compilation. But POSIX systems in general should be compatible, with a few changes here and there.

Ports to other operating systems that have been discussed on the message board are (somewhat out-of-date list):

Beyond this, visit the page Installation for a more up-to-date list of known (unofficially) supported platforms.

1.3 Why isn't there a Windows port of OpenFOAM ?

Actually, nowadays, there are a few ports for Windows. The only feasible way in the past, was to port OpenFOAM to Windows using Cygwin, an application that implements the most common UNIX APIs on Windows. Now MinGW is the more popular porting solution, because while it still integrates parts of Cygwin (MinGW forked from version 1.3.3 of Cygwin [1]), it can run natively in Windows and be linked with other native Windows libraries and applications.

One problem is that the file-system NTFS, that is used by most modern Windows Versions, is (by default) only case-preserving (hello.c and Hello.C are the same file, when in the same folder). The OpenFOAM-sources need a fully case-sensitive file-system and can't even be unpacked properly on a Windows system (see [2]). There is a possibility of enabling full case-sensitivity in Windows [3], but can lead to some Windows programs to not work properly.

1.3.1 (Cross-)Compiling with Cygwin

A (relatively old) way to compile OpenFOAM on cygwin is described on the Message-Board. The resultant binary distribution of version 1.3 is available here (and there is a relating discussion thread on the Message-Board). This port does not include FoamX and paraFoam, although postprocessing can be done with ParaView by using foamToVTK, and FoamX exists for OpenFOAM 1.4.x. This port is not part of the official distribution.

Another unofficial port of OpenFOAM 1.4.x is available here, with FoamX and ParaView. Support is available here and here.

FreeFOAM should prove to be more successful, but it's still in development, and uses CMake instead of wmake.

Cygwin 1.5 introduced a mount type named managed mounts, that can handle fully case sensitive files and folders, and some special characters that Linux can use and Windows can't [4]. In theory, if OpenFOAM is built under this interpretation layer, than it should be compilable directly in Windows. After some testing, it was discovered that OpenFOAM has some very long path names, which aren't handled properly by Cygwin's managed mounts, due to path size limit [5].

With Cygwin 1.7, managed mounts were dropped and POSIX mounts were introduced [6], as well as file paths increased to 4096 characters [7]. The POSIX mount relies on a hidden feature of Windows [8], that enables NTFS POSIX compatibility system, also used by Interix's SFU/SUA [9], thus enabling full case sensitivity. In other words, as of Cygwin 1.7, it is possible to compile and cross-compile OpenFOAM directly in Windows, without major reconstruction of the files and structure of the source code. Nonetheless, the whole build system has to be done under Cygwin's layer, because the flag obcaseinsensitive doesn't actually make all of Windows applications aware of full file name case sensitivity. For more information, see Using Cygwin for cross-compiling OpenFOAM.

1.3.2 (Cross-)Compiling with MinGW

There are already a few variants of cross-compiling with MinGW and one port that compiles directly in Windows with MinGW and CodeBlocks. The complete list is available here in the wiki. This link is part of a full step-by-step tutorial on how to Cross Compile OpenFOAM in Linux for Windows with MinGW and Mingw-w64.

1.4 How do I port OpenFOAM to an unsupported platform ?

If your platform is not some kind of UNIX-flavour you're probably going to have a hard time.

For a starter see Porting to a new platform.

1.5 Why is OpenFOAM built and installed in my home directory ?

Building and installing and running OpenFOAM in your home directory gives you some advantages. It is common practice to share the home directories across all machines machines on a network. In this setup all computers will have access to and run the same binaries compiled by the same compiler to help ensure consistent results. It also makes sharing data for cluster work easier. Also to really leverage the power of OpenFOAM you will want to write code to link to and extend it. If it was installed in a common directory individual users programs could clash via naming conflicts etc...

Unfortunately this is not a winning situation for everybody. If you build and install OpenFOAM in your home directory you can't use it on heterogeneous machines on a network, i.e. a z80 based machine cannot run OpenFOAM compiled for a 6502 based machine, unless it has emulation software in which case it would be slow. Fear not because it is possible to configure OpenFOAM to compile and install in a common directory on each machine to accommodate heterogeneous machines on a network.

1.6 Why am I not able to install the official OpenFOAM Deb packages on Ubuntu ?

If when following the instructions from the official instructions, e.g. Download v2.2.1 | Ubuntu, you get an error like this:

The following packages have unmet dependencies:
 openfoam221 : Depends: g++ but it is not installable
               Depends: libreadline-dev but it is not installable
               Depends: libopenmpi1.3 but it is not going to be installed
               Depends: libptscotch-5.1 but it is not going to be installed
               Depends: flex
               Depends: libscotch-dev but it is not going to be installed
               Depends: libopenmpi-dev but it is not going to be installed
               Depends: libxt-dev but it is not going to be installed
               Depends: openmpi-bin but it is not going to be installed
               Recommends: libptscotch-dev but it is not going to be installed
E: Unable to correct problems, you have held broken packages.

Then the problem is that the necessary repository universe is not installed, as explained here: Repositories/Ubuntu

To fix the problem, follow these steps:

  1. Edit the file /etc/apt/sources.list:
    sudo nano /etc/apt/sources.list
  2. You should find contents similar to this:
    # /etc/apt/sources.list
    deb http://archive.ubuntu.com/ubuntu/ precise main restricted
    deb http://security.ubuntu.com/ubuntu/ precise-security main restricted
    deb http://archive.ubuntu.com/ubuntu/ precise-updates main restricted
  3. Append to each line the word universe (you can add multiverse as well if you want to):
    # /etc/apt/sources.list
    deb http://archive.ubuntu.com/ubuntu/ precise main restricted universe
    deb http://security.ubuntu.com/ubuntu/ precise-security main restricted universe
    deb http://archive.ubuntu.com/ubuntu/ precise-updates main restricted universe
  4. Hit the key combination Ctrl+X, press the Y key, then the Enter or Return key.
  5. Now, update the list of packages by running:
    sudo apt-get update

And it's done. You can now proceed with the official installation instructions: OpenFOAM Download and Installation

1.7 Building and installing ParaView

See Installation/ParaView/FAQ.

1.8 Why do I get the error message "fileName::stripInvalid() called for invalid"?

There are several threads at the CFD-Online Forums which give examples of such situations. One of the most describing one is this: reconstructPar --> fileName::stripInvalid() called for invalid fileName commandtouse

In summary, this error message always appears when a file name is provided that OpenFOAM considers invalid. This is because OpenFOAM follows a strict rule to use file names as if they were C/C++ coding names, where the following characteristics must be followed:

  • A name can start with an alphabet character or an underscore.
  • A name cannot have spaces in it.
  • A name cannot start with a digit (0 to 9), but it can have digits in any other place of its name.
  • A name cannot have quote symbols, namely: " '
  • A name can be a composite of several names, by using dots and parenthesis, namely: . ( )
  • A name cannot have unconventional symbols, including there characters: \ / : ; , |

This rule mostly applies to the names of items inside OpenFOAM dictionaries, where the only exception is regular expressions can be used inside dictionaries.

1.9 How to run the tutorials in OpenFOAM?

First of all, the tutorials being referred to here are the ones addressed in the introduction of chapter 2 in the OpenFOAM User Guide. In other words, the tutorials folder to be used, should be a copy of the original copy of tutorials, which can be done by running:

mkdir -p $FOAM_RUN
cd $FOAM_RUN/tutorials

which will create the default running folder, then copy the tutorials to said folder and then switch to the folder with our new copy of the tutorials. If you're wondering where this folder is located, run:

echo $FOAM_RUN

Now please study chapter 2 in the OpenFOAM User Guide.

Once the chapter is studied, here are a few guidelines regarding OpenFOAM's tutorials:

  1. The simplest way to run a tutorial in OpenFOAM is to run blockMesh followed by the name of the solver, such as icoFoam. To know the name of the solver in question, have a look into the file system/controlDict and see the name defined for the keyword application.
  2. But the situation changes when the case is more complicated. In those cases, there are a couple of helper scripts inside the case folder or inside the parent folder of that case, named Allrun and Allclean. To run them, simply prepend ./ to the script's name, e.g.:
    Some examples of tutorials that have these scripts:
    1. In OpenFOAM 2.1, the tutorial incompressible/simpleFoam/motorBike has got the Allrun script.
    2. Also in OpenFOAM 2.1, the tutorial incompressible/icoFoam/cavity does not have the Allrun script, but the parent folder incompressible/icoFoam does have that script. This means that this Allrun script will run all tutorials within the folder incompressible/icoFoam.

1.10 Common errors when building OpenFOAM from source code

This section of the FAQ addresses many of the known common building errors that can occur when building OpenFOAM from source code. It is not a thorough list, but it should at least help with some of the more common issues.

In addition to this, please keep in mind to use a compiler version which is known to be compatible with OpenFOAM, for which a list is being kept in the page Installation/Compatibility_Matrix.

1.10.1 icoFoam or blockMesh cannot be found?

Something went wrong when you tried to build OpenFOAM, but didn't notice it until you tried to run icoFoam or blockMesh and got a message like this:

blockMesh: command not found

And/or perhaps you did notice an error at the end of the build, something like this:

make: *** [multiphase] Error 2
make: Target `application' not remade because of errors.

Well, both issues are likely related. To diagnose what in fact went wrong, run the Allwmake script once again like this:

./Allwmake > log.make 2>&1

This will make a full log into the file log.make, including errors that are outputted during the building process (i.e. "2>&1" does the redirect of stderr to stdout).

You can then check if there are any errors by opening the file log.make with a text editor and search for lines have the expression "Error " (including the space after the word "Error"). Keep in mind that if your terminal is returning error messages in another language, then you should search for the respective word for "Error".

If you do find errors, the first one is usually the one to blame for all of the other errors after that. Unless of course you've spotted the error explained in the subsection below, namely: Weird error message: make: [install] Error 1 (ignored) - what does it mean? - in that case, you can ignore that particular error message and search for the next one, if there is any.

Once you've spotted the first real error message, search online for the main keywords in that error message, because it has likely already been found by other people and already solved.

1.10.2 Compilation error, something about triad.C:36, what's wrong?

As of OpenFOAM 2.2.0 it was no longer possible to compile OpenFOAM with GCC 4.4 and older. At that time the limitation was introduced in a somewhat artificial way, because the authors no longer could support building OpenFOAM with all versions of GCC from 4.3 to 4.8.

The error message in question is as follows:

primitives/triad/triad.C:36: error: expected initializer before '<' token
primitives/triad/triad.C:39: error: expected initializer before '<' token

More detailed information about this is provided on the following forum thread: Compile Error of OpenFOAM-2.2.0 on RedHat EL5 - but the short solution is simple: upgrade to using GCC 4.5 or newer.

1.10.3 Weird error message: make: [install] Error 1 (ignored) - what does it mean?

This error message usually occurs when building the Scotch library, through OpenFOAM's Allwmake script in the ThirdParty-* folder:

cp: cannot stat `../bin/d[agm]*': No such file or directory
make: [install] Error 1 (ignored)

This particular message occurs usually only occurs when cleaning up the Scotch building folder and can be ignored. If there are any problems, it's not because of this error message.

The explanation is simple: Scotch's building procedure requires one to build it directly in the source code folder, which makes it a requirement to clean up after the building and installation steps are complete, so that one can also build other architectures of OpenFOAM and Scotch. For example, if you need both 32 and 64-bit builds, you will need Scotch's source code folder to be cleaned from the previous build, so that the next build can occur with success.

1.10.4 CMake is refusing to configure my build of ParaView, what's going on?

Usually there are 2 situations where this can occur:

  1. When you're using a CMake version that is not compatible with the CMakeLists.txt present in the source code you're trying to build.
  2. When there is a conflict with another custom installation of CMake.

Therefore, the two above are somewhat related: either you need a newer CMake version or the one you're using is too new. Either way, you will likely have to build a custom CMake version.

For ideas on how to build CMake from source code, please refer to the pages dedicated to detail how to install OpenFOAM and ParaView on Linux: Installation/Linux. For example, see the step #12 on this page/section: Installation/Linux/OpenFOAM-2.2.2/Ubuntu#Ubuntu_10.04

But if the custom build you've made of CMake on purpose for a specific OpenFOAM version isn't working as intended, then perhaps you're getting an error message like this one:

CMake Error at /opt/cmake/Modules/CMakeTestCCompiler.cmake:52

This was discovered in the following forum thread: openfoam 2.3.0 installation in RHEL 5. The solution was as simple as running:


Then you should be able to use the custom build of CMake you've made for building ParaView.

1.10.5 wget keeps complaining something about an insecure connection?

The error message in question is for example this one:

ERROR: certificate common name `www.github.com' doesn't match requested host name `raw.github.com'.
To connect to raw.github.com insecurely, use `--no-check-certificate'.

As the error message implies, you can use the option --no-check-certificate when using wget. Another somewhat easier solution is to run the following command, before running wget several times:

alias wget="wget --no-check-certificate"

As the command implies, it's an alias for the command wget, which will automatically use the options defined in the command above.

Now, please keep in mind that this can be considered a security risk, because this means that you'll be accessing a secure website through HTTPS, but without a valid certificate for said communication. This is usually because the local copy of the certificate list installed on your system is outdated and you can still go ahead safely with the download. But in some situations it might mean that either the target website is in fact insecure/compromised or that there is a man-in-the-middle attack going on; this could at the very least mean that the data you're getting might be getting corrupted on download.

1.10.6 Unable to build setSet without readline?

The error message occurs something along these lines:

Found <readline/readline.h>  --  enabling readline support.
Making dependency list for source file writePointSet.C
Making dependency list for source file writeFuns.C
Making dependency list for source file writePatch.C
Making dependency list for source file setSet.C

... fast-forwarding a bit to the error message:

Make/linux64GccDPOpt/writePatch.o Make/linux64GccDPOpt/setSet.o -L/home/ofuser/OpenFOAM/OpenFOAM-2.3.0/platforms/linux64GccDPOpt/lib \
	     -lmeshTools -lreadline -lOpenFOAM -ldl   -lm -o /home/ofuser/OpenFOAM/OpenFOAM-2.3.0/platforms/linux64GccDPOpt/bin/setSet
/usr/bin/ld: cannot find -lreadline
collect2: ld returned 1 exit status
make: *** [/home/ofuser/OpenFOAM/OpenFOAM-2.3.0/platforms/linux64GccDPOpt/bin/setSet] Error 1

Notice the very first line on the start of this description? Namely "enabling readline support"? The reason for this is that the readline library is only partially installed, where the header is present but the respective library isn't.

The quickest solution is to build setSet like this:

$FOAM_UTILITIES/mesh/manipulation/setSet/Allwmake NO_READLINE

If all goes well, it will have built setSet successfully without the readline library.

1.11 Uncommon errors when building OpenFOAM from source code

This section of the FAQ addresses many of the known and very rare building errors that can occur when building OpenFOAM from source code. It is not a thorough list, therefore please do add more as needed.

1.11.1 Wrong createFields.H file is included?

This was detected while debugging report #2386 at the OpenFOAM Foundation bug tracker.

The error was as follows:
In file included from /home/ofuser/OpenFOAM/OpenFOAM-4.1/src/OpenFOAM/lnInclude/postProcess.H:129:0,
                 from coldEngineFoam.C:47:
../XiFoam/createFields.H: In function ‘int main(int, char**)’:
../XiFoam/createFields.H:3:9: error: ‘psiuReactionThermo’ was not declared in this scope
 autoPtr<psiuReactionThermo> pThermo
CPLUS_INCLUDE_PATH the environment variable was incorrectly defined. For example, if the following command:
 export | grep  CPLUS_INCLUDE_PATH
shows something like this:
then the colon at the end is breaking the installation path. It seems to be a hard to reproduce bug in GCC, where an open definition of a path will lead to the first directory include path -I. be ignored.
Either unset the shell variable, for example by running:
or correct it, for example by running:
export CPLUS_INCLUDE_PATH="/home/ofuser/installed/hdf5/include"

1.11.2 Strange error message: target pattern contains no `%'. Stop.

This was (at least) detected back in 2012, namely here: OpenFOAM 2.1.1 Installation Errors on RHEL 6.3

The error was as follows:
$HOME/OpenFOAM/OpenFOAM-2.1.1/wmake/Makefile:148: *** target pattern contains no `%'. Stop.
$HOME/OpenFOAM/OpenFOAM-2.1.1/wmake/Makefile:148: *** target pattern contains no `%'. Stop.
GREP_OPTIONS was set in the shell environment with the option -n for also listing the lines where it occurs, which is used by grep, but which can affect all calls to this application, including within OpenFOAM's scripts and give weird outputs.
Unset this variable and use an alias instead. For example, by running the following commands:
alias grep='grep --color=auto'

1.11.3 Unable to source the file etc/bashrc, unless I use the complete path?

This was reported in #2310 at the OpenFOAM Foundation bug tracker.

Valid versions: OF Version 40.png OF Version 41.png

If the relative path to etc/bashrc is used for sourcing/activating the OpenFOAM environment, the following error will occur:
$ source etc/bashrc
bash: cd: etc/bashrc: Not a directory
bash: /OpenFOAM-4.1/etc/config.sh/functions: No such file or directory
bash: /OpenFOAM-4.1/bin/foamEtcFile: No such file or directory
bash: /OpenFOAM-4.1/bin/foamCleanPath: No such file or directory
bash: /OpenFOAM-4.1/etc/config.sh/functions: No such file or directory
This was a bug that was introduced before OpenFOAM 4.0 was released, but it was fixed with the aforementioned bug report #2310.
Solution 1
Do the modification mentioned in the respective commit 423ac54eabed at OpenFOAM 4.x, which is the following change to the file etc/bashrc:
-export FOAM_INST_DIR=$(cd ${BASH_SOURCE%/*/*/*} && pwd -P) || \
+export FOAM_INST_DIR=$(cd $(dirname $BASH_SOURCE)/../.. && pwd -P) || \

Valid versions: OF Version 4.pngOF Version FoundationDev.png

Solution 2
As described in bug report #2310, it is possible that the shell environment CDPATH may be interfering. To check if it is affecting this, by running the following command:
echo $CDPATH
and if it outputs anything, then unset it:
unset CDPATH

1.12 How to uninstall/remove OpenFOAM?

It all depends on how you installed it in the first place:

1.12.1 Common to all instructions

You need to fix your personal ~/.bashrc file, in order to remove the command line that loads the OpenFOAM shell environment. For more details, please refer to the section: Using aliases to help manage multiple OpenFOAM versions in the page Installation/Working_with_the_Shell.

1.12.2 Built from Source Code

If you built from source code (and assuming you didn't do anything outside of the usual steps), the removal/uninstallation steps are as follows:
  1. Go to the base folder where your OpenFOAM installation is located. For example:
    cd ~/OpenFOAM
  2. Now check the contents of this folder:
    ls -l
  3. Now you can try to remove the desired version, for example:
    rm -r OpenFOAM-2.3.0 ThirdParty-2.3.0
  4. Now check below the paragraph entitled "Common to all instructions".

1.12.3 Installed from Deb packages

If you installed on Ubuntu by following the Deb packages installation instructions, for example the official installation instructions for: Download v2.3.0 | Ubuntu - then you need to revert the installation steps used. For example, if the installation steps were these:
sudo apt-get install openfoam230 paraviewopenfoam410
then the command to remove/uninstall is this:
sudo apt-get remove openfoam230 paraviewopenfoam410
Now check below the paragraph entitled "Common to all instructions".

1.12.4 Installed from RPM packages

Here is depends on whether you installed on Fedora/RHEL or openSUSE:
  • Instructions for installing on Fedora are for example given here: Download v2.1.1 | Fedora - in this case, the uninstallation/removal command is:
    sudo rpm -e OpenFOAM-scotch-5.1.12-1 OpenFOAM-ParaView-3.12.0-1 OpenFOAM-2.1.1-1
    The same is applicable for RHEL.
  • Instructions for installing on openSUSE are for example given here: Download v2.1.1 | SuSE - in this case, the uninstallation/removal command is:
    sudo rpm -e OpenFOAM-scotch-5.1.12-1 OpenFOAM-ParaView-3.12.0-1 OpenFOAM-2.1.1-1
  • Note: the difference between Fedora/RHEL and openSUSE is pretty much none in these examples, because both used the rpm command for installing, therefore for uninstalling the same should be used. But the major difference between the two is the package manager:
    • For removing packages on Fedora/RHEL:
      sudo yum remove package_name
    • For removing packages on openSUSE:
      sudo zypper rm package_name
Now check below the paragraph entitled "Common to all instructions".

1.12.5 Uninstall container from Docker

This is essentially explained here: [OpenFOAM.com] A simple question: how to uninstall OpenFOAM v1712? - post #4

1.13 What is root mode?

All Operating Systems usually have at least one administrator account, which is able to control all aspects of how the operating system that is installed in a computer (aka machine) and what other global installation packages are available to the users of that machine. In Linux and most Unix-like operating systems, there is a primary account named root, which is the primary (and usually only) administrator account (also known as the super-user).

To switch into root mode requires to either:

  1. Login as root, instead of logging in a as normal user. Note: Do not login as root for using the Desktop interface.
  2. Or start a new terminal/console and explicitly switch to root:
    su -
    Note: You can exit root mode by running:
  3. Or start a new terminal/console and implicitly switch to root using sudo (if you have premissions):
    sudo -s
    Note: You can exit root mode by running:
  4. Or in a new terminal/console use sudo (if you have premissions) to run the desired command, for example:
    sudo apt-get update

And how can you know if you're in root mode? Run in the terminal/console/command line:


If it tells you:


then you're in root mode.

1.14 Why am I getting "Permission denied" when I try to run a local script or application?

Sometimes when you run a local script, the command line will tell you that the permission is denied to do so. For example the Allrun scripts that OpenFOAM has got in its tutorial folders, which you're meant to run like this:


You might get an error message like this one:

bash: ./Allrun: Permission denied

There are at least two possible reasons for this to happen:

  1. In UNIX-like file systems (used in Linux and sometimes in Mac OS X), the files also need to have defined the permission executable. In order to give the permission to execute the script or application, you need to run chmod with the +x option. For example, run this command:
    chmod +x Allrun
    for giving the execution permission to the file Allrun.
    • This is because in these file systems, files and folders have at least types of permissions per category: read, write and executable. For more details, read about chmod.
    • In contrast, other operating systems (like Microsoft Windows) will simply rely on the file extension in order to know if the file is executable or not, for example: calc.exe where .exe is what tells the operating system that this file alleges to be executable.
  2. The other possibility is if you are trying to run the script inside a folder where you don't have enough permissions to use this folder and its contents. For example, if the folder is defined as read-only. In such a situation, there are two possible workarounds:
    1. If the folder is located in a read-only location, such as /opt/openfoam240/tutorials/incompressible/icoFoam/cavity, then it's advisable to make a copy to your own work folder, for example by running:
      cp -r /opt/openfoam240/tutorials/incompressible/icoFoam/cavity $FOAM_RUN/myCavity
    2. If the folder is already in your personal working folder path, then you need to either:
      • Change the write permissions for the folder, for example:
        chmod -R +w myCavity
        • -R is for recursively go into sub-folders.
        • +w is for making it writable.
      • Or change the ownership of the folder and files:
        chown -R user:group myCavity
        • The user is meant to be your user-name. When in doubt, run:
        • The group is meant to be the main group your user-name is assigned to. When in doubt, run:
          id -gn
        • Example:
          chown -R ofuser:users myCavity

1.15 Common problems and solutions for building software from source code that is in the ThirdParty folder?

The lists of common problems for each Third-Party software that OpenFOAM relies on is being maintained on dedicated pages. The sections on the wiki dedicated to that software is listed in the Category:Installing Third-Party software.

For example, FAQ pages already exist for ParaView and CGAL:

Facts about "FAQ/Installation and Running"RDF feed
FaqdescriptionProblems with the installation and running of applications +
FaqnameInstallation and Running +
Faqnumber2 +