Skip to content

Building from source code

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

Building dmidiplayer

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 dmidiplayer's CMake buildsystem. The following examples assume that you are working on Linux.

Download Drumstick and dmidiplayer

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

projects/
├── drumstick
└── dmidiplayer

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/dmidiplayer.git dmidiplayer

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 Qt6 installed at your home directory (~/Qt/6.8.1/gcc_64). There are many other cmake options that you may add.

$ pwd
/home/username/projects/drumstick/
$ cmake -S . -B build/ -DCMAKE_BUILD_TYPE=Debug -DCMAKE_PREFIX_PATH:STRING="$HOME/Qt/6.8.1/gcc_64;$HOME/Fluidsynth3;$HOME/Sonivox"
...
-- 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 dmidiplayer

First, create a build directory like the other one:

$ cd ~/projects
$ cd dmidiplayer
$ mkdir build

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

$ pwd
/home/username/projects/dmidiplayer
$ cmake -S . -B build/ -DCMAKE_PREFIX_PATH=~/Qt/6.8.1/gcc_64 -DCMAKE_BUILD_TYPE=Debug -DDrumstick_DIR=~/projects/drumstick/build
-- The CXX compiler identification is GNU 12.3.1
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/c++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Current revision (Git) is add112c
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD - Success
-- Found Threads: TRUE  
-- Found OpenGL: /usr/lib64/libOpenGL.so   
-- Found WrapOpenGL: TRUE  
-- Found XKB: /usr/lib64/libxkbcommon.so (found suitable version "1.4.1", minimum required is "0.5.0") 
-- Found WrapVulkanHeaders: /usr/include  
-- Performing Test HAVE_STDATOMIC
-- Performing Test HAVE_STDATOMIC - Success
-- Found WrapAtomic: TRUE  
-- Found Cups: /usr/lib64/libcups.so (found version "2.4.7") 
-- Drumstick MIDI File Player v1.7.5
     install prefix: /usr/local
     Build configuration: Debug
     Operating System: Linux
     Processor: x86_64
     Qt Version: 6.8.1
     Drumstick Version: 2.10.0
     Uchardet Version: 0.0.8
-- Found Git: /usr/bin/git (found version "2.42.0") 
-- Configuring done (1.3s)
-- Generating done (0.0s)
-- Build files have been written to: /home/username/Projects/dmidiplayer/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 dmidiplayer now using cmake --build command and you are done. To execute dmidiplayer 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/dmidiplayer

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:

uchardet >= 0.0.8 is also required.

Linux

On Linux, The GCC compiler is provided by your Linux distro. dmidiplayer 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.