# Build

## Build the project

### Step: Build with Visual Studio

Open the OGS.sln (in the build directory) either by double-clicking it in the file browser or opening in Visual Studio via File / Open / Project.

On the project explorer right-click on ogs or ogs-gui and choose Set as startup project. Then press F5 or click the green arrow to build and start the project.

#### About Visual Studio startup projects

The reason for this is that you can have only one sub-project of your Visual Studio Solution activated for debugging (e.g. by pressing F5). Per default this is the first sub-project (in the case of a CMake-generated project this is ALL_BUILD). This must be manually set to a sub-project which generates an executable (a library sub-project cannot be started). And because this setting is stored in user specific project file it cannot be set via CMake.

### How to work with CMake and Visual Studio

You can work normally in Visual Studio but remember that you have to make project changes in the CMakeLists.txt-file and not inside Visual Studio. So you can add a new source file within Visual Studios File menu but you have to add that file also to the CMake file. Every time you change a CMakeLists.txt and you build the project a new CMake run is automatically invoked. After that Visual Studio informs you that the project files were changed and it reloads them.

### With ninja

To build with the ninja tool on the shell go to your previously configured build directory and type ninja:

cd ../build/release
ninja


### Exceeding memory consumption during compilation

By default, ninja uses maximum parallelism which may lead to a memory consumption exceeding the available memory (especially when compiling the processes).

Therefore, we recommend restricting the number of parallel compilations to be used to one per 8 GB RAM, e.g., if your machine has 16 GB RAM type ninja -j 2 for a maximum of two parallel compilations.

Another option is to build just the process you are interested in by configuring with the CMake option OGS_BUILD_PROCESSES, e.g.: cmake -DOGS_BUILD_PROCESSES=HT ..... In this case you should be able to compile with full parallelization.

### Build with CMake presets

Similar to the configure presets there are build presets, e.g. in your source-directory:

cmake --build --preset release             # equivalent to running ninja above
cmake --build --preset release -j 2 -t ogs # build the ogs-target with 2 threads


See Linux-tab!

## Waiting

So now the build process is running… This can take some time because maybe there are external libraries which get automatically downloaded and compiled. This step is only done once per build directory, so subsequent builds will be much faster. See this for more.

## Finished

Congratulations you have finished the Getting Started-section!

Have a look at the other sections of this guide. Check out Development Workflows if you are interested in actively contributing to the project. The Configuration Options-page shows you all available build customizations. Go ahead!

This article was written by Lars Bilke. If you are missing something or you find an error please let us know. Generated with Hugo 0.79.0. Last revision: August 26, 2021
Commit: [CMake] Disable -march flag on Apple ARM processors. 93c389cefe  | Edit this page on