Build on Windows

In case you want to change stuff in the source code or want to achieve a local installation, you should proceed as follows. The recommended way is to checkout the source code of NGSolve. During the process Netgen will be automatically downloaded and built.

Prerequisites

Make sure that you have the following packages installed

  • You need a recent compiler, we advise Microsoft Visual Studio 2015

  • Python 3.7: You can get it here if you don't already have it. Make sure to download one of the "x86-64" installers. Also make sure to select the option "Add Python 3.7 to PATH" during the installation.

  • cmake to generate Visual Studio Projects Files (Win32 Installer works for both architectures) we recommend the install option 'Add CMake to the system PATH for all users'

  • git for downloading Netgen/NGSolve sources

Directory structure

For ease of presentation we use a directory structure with three main directories:

  • "src" for the source code NGSolve

  • "build" for the output of CMake and the compiler

  • "install" for the actual installation

In the following we assume that you have chosen a base directory where three (empty) directories "src", "build" and "install" have been created. This base directory will be denoted as BASEDIR in the following.

Getting the source

Start "Git Bash", navigate to BASEDIR and execute

git clone https://github.com/NGSolve/ngsolve.git src

Go to the source directory and initialize the git submodules to download the source files for Netgen and Pybind11.

cd src
git submodule update --init --recursive
cd ..

After this step you should have the source code of Netgen in src/external_dependencies/netgen.

Configuring

Next, change to the "build" directory and use cmake to configure from the sources. The standard configuring command looks like this:

mkdir build
cd build
cmake "../src" -DCMAKE_INSTALL_PREFIX="BASEDIR/install" -G "Visual Studio 14 Win64"

There are many options for cmake, which you can find using

cmake --help

Building

To build Netgen/NGSolve, exectue

cmake --build . --config Release --target install

Alternatively you can open BASEDIR\build\SUPERBUILD.sln in Visual Studio and build the "INSTALL" project. Make sure to select the desired solution configuration (e.g. Release).

Finishing the installation

Finally you have to set the environment variables PATH, NETGENDIR and PYTHONPATH to the appropriate values. This is done by building the "set_environment_variables" target:

cmake --build . --config Release --target set_environment_variables