Building from source


We require a number of libraries and frameworks that are not part of OPM itself to be installed before you can build. For instructions see the prerequisites page. Most prerequisites usually have installable packages available (depending on your OS or distro).

Also, while it is possible to have installed binary package versions of OPM modules on your system at the same time that you build/use OPM from source, it is a typical source of hard-to-find errors. We therefore recommend that you uninstall the opm binary packages before you start building from source.

Build order

Build the opm modules in the following order:

  1. opm-common
  2. opm-grid
  3. opm-models
  4. opm-simulators
  5. opm-upscaling

Not every item depends on everything above it, but all depend on at least one item above it. ResInsight is quite independent, and can be built without any of the other modules. For more information, there is a module overview.

This structure is subject to change: it is likely that new modules will appear, and existing modules will be combined or restructured. We are currently working on reducing the number of modules to simplify the structure.

Build instructions

First, you should use git to clone the source repositories, like this:

git clone[modulename].git

Alternatively, you can download the release tarballs. We recommend that you put all the modules in a single directory. Then, to build any module,

mkdir [modulename]/build
cd  [modulename]/build
cmake ..

Since some modules depend on others, you may save yourself trouble by building the modules in the order given above, starting with opm-common.

Tips and tweaks

To do all of this in one go, you can try this bash script:

for repo in opm-common opm-grid opm-models opm-simulators opm-upscaling
    echo "=== Cloning and building module: $repo"
    git clone$repo.git
    mkdir $repo/build
    cd $repo/build
    cmake ..
    cd ../..

To speed up compilation on a multicore machine, you may want to use for example on a 8-core machine:

make -j 7

This will start 7 parallel compilation jobs, leaving one core for other things.

You may need to customize the build process in order to specify compiler options, nonstandard library locations, build type and more. Then replace the cmake command with:

cmake -C options.cmake ..

The options.cmake file contains your customization. CMake syntax must be used, an example of such an options file is given below. It specifies that you want a Debug build (the default is Release) and not use OpenMP.

set(CMAKE_BUILD_TYPE "Debug" CACHE STRING "Build type")
set(USE_OPENMP OFF CACHE BOOL "Do not use OpenMP")

MPI support is activated by default.
If you want to build with Python bindings for the parser and the simulator, the you must turn it on in the call to cmake. Do this by adding the “-DENABLE_PYTHON=ON -DENABLE_EMBEDDED_PYTHON=ON -DOPM_INSTALL_PYTHON” option to the cmake calls, or if using an options.cmake file add the line


to your options.cmake file.

Finally, if you built and installed the prerequisites Dune and/or Zoltan yourself instead of by installing binary packages for them, you may need to specify their installed locations on the cmake command line, do this by adding


to the command, replacing /first/path etc by the locations you installed the libraries to.