Skip to content
Tom M edited this page Dec 2, 2017 · 41 revisions

Building FluidSynth with CMake

What is CMake?

CMake is a cross platform build system, that can be used to replace the old auto-tools, providing a nice building environment and advanced features. Some of these features are:

  • Out of sources build: CMake allows you to build your software into a directory different to the source tree. You can safely delete the build directory and all its contents once you are done.
  • Multiple generators: classic makefiles can be generated for Unix and MinGW, but also Visual Studio, XCode and Eclipse CDT projects among other types.
  • Graphic front-ends for configuration and build options.

More information and documentation is available at the CMake project site

CMake is free software. You can get the sources and pre-compiled packages for Linux and other systems.

You need CMake 3.0.2 or later to build FluidSynth.

Requirements

Some other libraries can be optionally included at build time, providing additional functionality.

Common Tips

Get the FluidSynth sources somewhere.

Execute CMake from the build directory, providing the source directory location and optionally, the build options. There are several ways.

  • From a command line shell:

    $ pwd
    fluidsynth-x.y.z
    $ mkdir build
    $ cd build
    $ cmake ..
    

The last command (cmake ..) can be modified by adding options. Common modifications include e g:

  • -DLIB_SUFFIX= - make sure we don't put anything in /lib64, this is needed on 64 bit Debian/Ubuntu platforms
  • -DCMAKE_INSTALL_PREFIX=/usr - this will overwrite instead of override an existing FluidSynth installation
  • -Denable-ladspa=1 - ladspa is disabled by default, this will enable that functionality
  • -DCMAKE_BUILD_TYPE=debug - if you want to help out and find bugs, this will make it easier to debug (but much worse performance)

Valid values for boolean (enable-xxxx) options: 1, 0, yes, no, on, off.

  • There are also several alternative CMake front-ends, if you don't want to use the command line interface:
    • ncurses based program, for Linux and Unix: ccmake
    • GUI, Qt4 based program, multiplatform: cmake-gui
    • GUI, Windows native program: CMakeSetup.exe

Here is a screenshot of cmake-gui configuring FluidSynth for Visual Studio 9 2008. You need to tell the program where is the source code and where you want the build directory. The program will prompt you which generator to run, you fill some options, and press two buttons:

  • Configure: checks the libraries corresponding to your selections. You can press this button several times after changing options (minimum twice), until you get your best configuration results.
  • Generate: once the configuration is successful and you are satisfied, it creates the project files.

Finally, execute the build command. If you generated a project file, use your IDE to build it. If you used the Makefiles generator (the default in Linux and other Unix systems) then execute make, gmake or mingw32-make.

There are many targets available. To see a complete list of them, type:

$ make help

The build process usually hides the compiler command lines, to show them:

$ make VERBOSE=1

There is a "clean" target, but not a "distclean" one. You should use a build directory different to the source tree. In this case, the "distclean" target would be equivalent to simply removing the build directory.

To compile the developer documentation you need Doxygen installed. Use this command from the root build directory:

$ make doxygen

Building on Linux

If your distribution already has a packaged FluidSynth sometimes you can grab the build dependencies automatically by running a command such as

sudo apt-get build-dep fluidsynth --no-install-recommends

(This would work under Debian/Ubuntu)

  • Note that after (un)installation (with "sudo make install" or "sudo make uninstall") you might need to run "sudo ldconfig" or you'll end up with a new executable calling the old library!

Building with MSYS2 on Windows

This is probably the easiest and most straightforward method.

Requirements

Environment setup

  1. Install MSYS2 in your preferred location and launch it.
  2. Run pacman -Syyu. Let it update, close the window when requested
  3. Launch MSYS2 again, either from the mingw32 (32 bit) or mingw64 (64 bit) shell. Choose based on your machine architecture.
  4. Run pacman -Syyu and update again. This time it should pull more packages.
  5. Once done, install all the dependencied needed by FluidSynth by running:

pacman -S make mingw-w64-x86_64-pkg-config mingw-w64-x86_64-gcc mingw-w64-x86_64-cmake glib2-devel mingw-w64-x86_64-glib2 mingw-w64-x86_64-libsndfile

This is just an example for 64 bit systems. If you are running the 32 bit version, replace x86_64 by i686.

Building

  1. Grab FluidSynths latest release tarball, as described here.
  2. Navigate into the source folder and create a new folder, we'll call it 'build'.
  3. Navigate into that folder and run cmake on the previous directory, specifying the Makefile type cmake -G "MSYS Makefiles" ..
  4. You're set. Run make to build.

Building with Cygwin on Windows

This method provides a full UNIX-like environment. You might run into weird issues with compiled code, such as FluidSynth trying to load Linux audio drivers, or not being able to run FluidSynth without the specific Cygwin DLLs!

Environment setup

Install Cygwin following the setup, and selecting at least the following packages (please note that they might already be marked for installation):

  • gcc
  • cmake
  • glib

Building

  1. Grab FluidSynths latest release tarball, as described here.
  2. Navigate into the cloned repository and create a new folder, we'll call it 'build'.
  3. Navigate into that folder and run cmake on the previous directory, specifying the Makefile type cmake -G "MSYS Makefiles" ..
  4. You're set. Run make to build.

Building with MinGW on Windows

If you want to use MinGW and set environment variables manually, please download glib and dependencies from gtk.org:

64-bit Windows:

32-bit Windows:

Unpack all required ZIPs (see above) to the same directory, a name without spaces, for instance C:\freesw. Add C:\freesw\bin to the system PATH by executing set PATH=C:\freesw\bin;%PATH%. To verify: Start button -> Command Prompt

C:\\> pkg-config --list-all
gio-2.0               GIO - glib I/O library
gmodule-2.0           GModule - Dynamic module loader for GLib
glib-2.0              GLib - C Utility Library
gmodule-no-export-2.0 GModule - Dynamic module loader for GLib
gthread-2.0           GThread - Thread support for GLib
gobject-2.0           GObject - GLib Type, Object, Parameter and Signal Library

For instance, this is the layout of the directory with the dependencies installed:

C:\freesw\
├───bin
├───include
│   └───glib-2.0
│       ├───gio
│       ├───glib
│       └───gobject
├───lib
│   └───glib-2.0
│       └───include
├───manifest
├───pkgconfig
├───share
│   ├───aclocal
(...)

CMake 3.9.6 is available from CMake official site. Let the installer to add CMake to the system PATH environment variable, and create a desktop shortcut icon.

Obtain dsound.h and copy it to C:\freesw\include. Either install the Microsoft DirectX SDK or alternatively try Google Code Search to locate a copy of the header file. Some users have mentioned that the header contained in Wine might work.

Note: For simplicity you can unzip the dependencies above directly into your MinGW installation directory.

Get MinGW, for convenience you can use the TDM Bundle installer (use at your own risk).

Run CMake, opening the desktop icon shortcut.

  • Select "MinGW Makefiles".
  • Select the directory containing FluidSynth sources, and another directory for building (e.g. ./build).

Start mingw32-make on the command line to build the project:

>cd
fluidsynth-x.y.z
>cd build
>mingw32-make.exe

Notes on compiling under Windows 10

Problem 1.

pkg-config was not found: Make sure the folder containing the pkg-config.exe is on the PATH env variable or copy the .exe to mingw32\bin folder.

Problem 2.

libintl.dll cannot be found (linker calls it intl):

Make sure libintl.dll is in a directory the linker is looking for (e.g.: c:/mingw32/lib/gcc/mingw32/6.3.0). It does not use the PATH variable. Make sure the filename of libintl.dll does not include the version.

Building with Visual Studio on Windows

You can get Visual Studio Express Community 2017, from Microsoft. Note: the Community 2017 edition supports many languages, but only C/C++ is needed. You don't need special options, just the defaults.

You can install glib using the vcpkg tool:

vcpkg install glib

Run CMake, opening the desktop icon shortcut.

  • Select "Visual Studio 2017".
  • Select the directory containing FluidSynth sources, and another directory for building.
  • Click "Configure"
  • Press "Generate"

Go to the build directory, and double click the file FluidSynth.sln, and build the solution.

Building on OS X

Get all requirements with Homebrew:

brew install fluidsynth pkg-config

Install XCode, "DevSDK.pkg" and "CoreAudioSDK.pkg" packages from your OS X install media.

Run CMake from your Applications:

  • Select "Unix Makefiles".
  • Select the directory containing FluidSynth sources, and another directory for building (e.g. ./build).

Start make on the command line to build the project:

>cd
fluidsynth-x.y.z
>cd build
>make.exe