Skip to content

Building from source code

Pedro López-Cabanillas edited this page Jan 26, 2025 · 4 revisions

Building VMPK with CMake

You may use CMake with Qt Creator or standalone from the command line shell. The first step is to download and build Drumstick with CMake, You may optionally install Drumstick, but you don't need to. Drumstick build directory may be used directly by the VMPK's CMake buildsystem. The following examples assume that you are working on Linux.

Download Drumstick and VMPK

Let's suppose that you use the following directory structure for your projects, in your $HOME directory:

projects/
├── drumstick
└── vmpk

Then you need to download or checkout the source code from both projects in your projects directory

$ cd projects
$ git clone https://github.com/pedrolcl/drumstick.git drumstick
$ git clone https://github.com/pedrolcl/VMPK.git vmpk

Build Drumstick

First, create a build directory inside (or outside) the project directory. There is already one in the Git repository.

$ cd ~/projects
$ cd drumstick
$ mkdir build

Second, call CMake with the arguments you prefer. For instance, if you have Qt 5.15.10 installed at your home directory (~/Qt/5.15.10/gcc_64). There are many other cmake options that you may add.

$ pwd
/home/username/projects/drumstick/
$ cmake -S . -B build/ -DCMAKE_PREFIX_PATH=~/Qt/5.15.10/gcc_64 -DCMAKE_BUILD_TYPE=Debug
...
-- Configuring done
-- Generating done
-- Build files have been written to: /home/username/projects/drumstick/build

Finally, if the configuration is satisfactory and without errors, you may proceed to compile the libraries, execute the unitary tests, and (optionally) if everything went well, to install it:

$ cmake --build build/
...
[100%] Built target manpages

$ ctest --test-dir build/

Running tests...
Test project /home/username/projects/drumstick/build
    Start 1: alsaTest1
1/4 Test #1: alsaTest1 ........................   Passed    0.00 sec
    Start 2: alsaTest2
2/4 Test #2: alsaTest2 ........................   Passed    1.03 sec
    Start 3: fileTest
3/4 Test #3: fileTest .........................   Passed    0.00 sec
    Start 4: rtTest
4/4 Test #4: rtTest ...........................   Passed    0.01 sec

100% tests passed, 0 tests failed out of 4

Total Test time (real) =   1.04 sec

$ sudo cmake --install build/

Building and running VMPK

First, create a build directory like the other one:

$ cd ~/projects
$ cd vmpk
$ mkdir build

Second, invoke cmake providing the Qt5 and Drumstick directories (unless you have installed Drumstick in your system).

$ pwd
/home/username/projects/vmpk
$ cmake -S . -B build/ -DCMAKE_PREFIX_PATH=~/Qt/5.15.10/gcc_64 -DCMAKE_BUILD_TYPE=Debug -DDrumstick_DIR=~/projects/drumstick/build
-- The CXX compiler identification is GNU 7.4.1
-- Check for working CXX compiler: /usr/bin/c++
-- Check for working CXX compiler: /usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- VMPK v0.7.3.99
     install prefix: /usr/local
     Build configuration: Debug
     Processor: x86_64
     Qt5: 5.15.10
     D-Bus support: ON
     Drumstick: 2.8.0
-- Found PkgConfig: /usr/bin/pkg-config (found version "0.29.2") 
-- Program pkg-config v0.29.2 found (/usr/bin/pkg-config)
-- Checking for module 'xcb'
--   Found xcb, version 1.13
-- Found XCB development libs v1.13
-- XSLTPROC Found: /usr/bin/xsltproc
-- Configuring done
-- Generating done
-- Build files have been written to: /home/pedro/projects/vmpk/build

$ cmake --build build/
[...]
$ sudo cmake --install build/
[...]

The argument -DDrumstick_DIR=~/projects/drumstick/build is taking the Drumstick libraries directly from their build directory. You can build VMPK now using cmake --build command and you are done. To execute VMPK before installing, you only need to define an environment variable with the location of the Drumstick plugins:

$ export DRUMSTICKRT=~/projects/drumstick/build/lib/drumstick
$ src/vmpk

Note: translations and other data files won't work until you install the program on your system.

That's all. Happy hacking!

Particularities of the target platforms

The build process is very similar on all supported target platforms (Linux, Windows and macOS) but there are some particularities worth noting.

You need on all platforms Qt6 (default) or Qt5 (deprecated). Depending on your operating system version and compiler, you need to check which version you can use:

Linux

On Linux, The GCC compiler is provided by your Linux distro. VMPK depends on some 3rd party packages to generate sound using synthesizers:

  • ALSA support is mandatory. You need to install the ALSA library development package
  • PulseAudio is recommended. You may install the native development package or the compatibility layer of PipeWire
  • FluidSynth is recommended.
  • Sonivox is the default synth on Linux. If you can't find the library on your Linux distro, then you will need to download the source code and build it yourself.

Windows

You can choose two supported tool chains: MSVC and MinGW, each one providing its own compiler and utilities.

  • To use MSVC, install the command line tools compiler, and also the vcpkg package manager, that provides for instance FluidSynth. It also provides Qt5 and Qt6 for x64, x86 and ARM64.
  • To use MinGW, the recommended way is Msys2 to install the compiler and libraries, for instance FluidSynth. It provides Qt5 and Qt6 for x64.

macOS

The Clang compiler is provided by Apple's XCode. The libraries can be provided by either vcpkg or Homebrew.