Skip to content

Building Hydrogen from source (Windows)

Sebastian Moors edited this page May 23, 2021 · 9 revisions

Introduction

Since Hydrogen 1.1, the easiest way to build Hydrogen from source is by using msys2. Msys2 is "Software Distribution and Building Platform for Windows" which provides all necessary packages for Hydrogen's dependencies. The packages already contain binaries, so the time-consuming compilation of dependencies can be omitted.

We're providing a powershell build script which automates the process of building Hydrogen (including the installation of most of the necessary dependencies). By using the script, the build process can also be done by non-developers and requires (in the best case..) only very basic skills.

In addition, this pages describes how to Debug Hydrogen on windows.

Limitation of this approach: There is currently no support for the Jack Audio Driver if you build Hydrogen via msys2.

Prepare your build system

Install msys2

Go to https://www.msys2.org/ and download the Installer. Run the installer on your system. Run the msys2 application afterwards. A terminal window will open.

In the next step we will install git. Note: It is not necessary to do that inside msys2, you may also use an already installed git client. If you feel unsure about this, just use the following steps.

Install git:

pacman -S git

Create a directory (whereever you want) and clone the Hydrogen git repository:

mkdir /c/hydrogen-src

cd /c/hydrogen-src

git clone https://github.com/hydrogen-music/hydrogen.git

You can close the msys2 terminal window if the repository has been cloned sucessfully.

Install python:

Install python from https://www.python.org/downloads/. The most recent version should be fine.

If you use the "Install now" feature, please memorize or write down the installation directory of Python. If you choose "Customize installation", make sure that pip support is enabled.

Building Hydrogen

First of all, we have to prepare the build script itself. Open the file windows\Build-WinNative.ps1 in your favourite text editor and set the variable $python_exe to the path of the Python interpreter. This is the path of your Python installation + "\python" (the filename of the python binary itself). In the end, it should look similiar to this line:

$python_exe=C:\python39\python

Now start the Windows Powershell and change to the windows directory in your copy of the Hydrogen git repository. Adjust the path names to whatever location you have chosen earlier for your git repository.

cd C:\hydrogen-src\hydrogen\windows

Now use our build skript to install all the required packages from msys2:

./Build-WinNative.ps1 -installdeps

If you're getting a permission error and haven't run any powershell script before, have a look here. This step has to run only once.

The next step builds Hydrogen:

./Build-WinNative.ps1 -build

To bundle all files into an installer, run:

./Build-WinNative.ps1 -deploy

The deploy steps ends with a message like CPack: - package: C:/src/hydrogen/build/Hydrogen-1.1.0-win64.exe generated.. Execute this file to install Hydrogen.

Note: If you want to create 32bit binaries, use -installdeps -32bit and -build -32bit.

Debugging Hydrogen

Debugging with Visual Studio might be the standard for Windows environments, it is not possible to debug msys2 applications. You can use gdb (from msys, for example mingw-w64-x86_64-gdb) or QtCreator (as a gdb frontend).

You can install QtCreator with pacman -S mingw-w64-x86_64-qt-creator. You will have to create custom build steps to build Hydrogen and to copy the main binary as well as the core dll to your local installation of Hydrogen.