Build under Windows

The following instructions have been tested under Windows 10 Pro.


Visual Studio

Download Visual Studio Community Edition from from the official website The current build instructions are tested with Visual Studio 2022.


Download Qt from from the official website

Make sure to choose the open source version of Qt and download the online installer.

Select Qt 5.15.2 (LTS) and open the sub tree. Only ‘MSVC 2019 64-bit’ component is needed.

Make a symbolic link to the directory corresponding to the current Qt version; e.g., if Qt 5.15.2 is installed in C:\Qt\5.15.2, then in Windows cmd (with administrative rights) execute:

$ mklink /D "C:\Qt\current" "C:\Qt\5.15.2"
$ mklink /D "C:\Qt\msvc" "C:\Qt\5.15.2\msvc2019_64"


Download the Windows x64 Installer from the official website

Python + Packages

Next up, download Python 3.9. For that, go to, look for Python 3.9.x and download the Windows installer (64-bit). Follow the setup and make sure to add Python to PATH.

Once Python is set up correctly, install numpy. Therefore open a PowerShell and type the command:

py -m pip install numpy

Analogously install matplotlib with

py -m pip install matplotlib

NSIS (for packaging only)

Download and install NSIS 3.03 from the official website. Add NSIS to the system PATH; see below.


If you want to re-build the Python-API with SWIG, download and install SWIG from the official website

Information can be found on []

Unpack the ZIP file and add its folder to PATH (so e.g. C:\swigwin-4.0.2)


Go to

From there download:

  • (complex error function, Voigt function etc)
  • libformfactor (TODO: will be provided when requested)
  • (fast Fourier transform)
  • (GNU Scientific Library)
  • (Support for TIFF images)
  • boost_1_77_0.7z (C++ Library boost, including BZIP2 and ZLib)

Create the folders


and paste the corresponding content from the ZIP files in those two folders.

System Enviroment Variables

After those installations your PATH should contain

C:\Program Files\Python39\Scripts\
C:\Program Files\Python39\
C:\Program Files\CMake\bin
C:\Program Files (x86)\NSIS


With all prerequisites completed, you should be able to build and test BornAgain in a PowerShell. In there, execute

$OPTLIBS = "C:/opt/x64"
$FFTW3_LIB = "$OPTLIBS/lib/libfftw3-3.lib"
$QTDIR = "C:/Qt/current/msvc2019_64"
$QTCMake_DIR = "$QTDIR/lib/cmake"
$BUILD_DIR = "build"

mkdir -Force "$BUILD_DIR"


cmake --build . --config Release

ctest -C Release --parallel 8 --output-on-failure

Build with Ninja (Experimental)

Compilation might be accelerated if Ninja is used as a build system. Download the Ninja binary for Windows from Add the binaries to a directory in your PATH; e.g. C:\Program Files\ninja.

To use Ninja as the build system, the compilation cannot be performed in a PowerShell but in the Visual Studio Shell x64 Native Tools Command Prompt for VS 2019 which you can search for in the start menu.

Use the following commands to build BornAgain:

set OPTLIBS=C:/opt/x64
set FFTW3_LIB=%OPTLIBS%/lib/libfftw3-3.lib
set QTDIR=C:/Qt/current/msvc2019_64
set QTCMake_DIR=%QTDIR%/lib/cmake
set BUILD_DIR=buildnj

mkdir "%BUILD_DIR%"
cd "%BUILD_DIR%"

cmake --version


echo "## BUILD START:" %time%
cmake --build . --config Release --parallel 8

echo "## BUILD END:" %time%
ctest -C Release --parallel 8 --output-on-failure