Using your environment¶
Building FluidSynth with CMake¶
Let's return to our original goal
of compiling FluidSynth using CMake as per its
official documentation.
To keep this example simple, we are not using any listed optional libraries. If you needed them you could either check if Spack can provide them (either from upstream or as a personal install), or manually compile them as needed.
To ensure that all required environment variables are activated for the environment, it is best to deactivate the environment and then re-activate it again to enable them:
spack env deactivate
spack env activate -p /gpfs/scratch/${USER}/spack-environments/spack-cmake
In the freshly activated environment:
Building FluidSynth with CMake (click to expand output)
[spack-cmake] $ cd /gpfs/scratch/${USER}
[spack-cmake] $ wget https://github.com/FluidSynth/fluidsynth/archive/refs/tags/v2.5.5.tar.gz
...
Saving to: ‘v2.5.5.tar.gz’
...
‘v2.5.5.tar.gz’ saved [2115530]
[spack-cmake] $ tar -xvf v2.5.5.tar.gz
...
[spack-cmake] $ cd fluidsynth-2.5.5
[spack-cmake] [fluidsynth-2.5.5]$ mkdir build
[spack-cmake] [fluidsynth-2.5.5]$ cd build
[spack-cmake] [build]$ cmake \
-DCMAKE_INSTALL_PREFIX=/gpfs/scratch/${USER}/fluidsynth-install \
-DCMAKE_C_COMPILER=gcc \
-DCMAKE_CXX_COMPILER=g++ \
..
-- The C compiler identification is GNU 12.2.0
-- The CXX compiler identification is GNU 12.2.0
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /share/apps/rocky9/spack/apps/linux-rocky9-x86_64_v4/gcc-11.4.1/gcc/12.2.0-6frskzg/bin/gcc - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /share/apps/rocky9/spack/apps/linux-rocky9-x86_64_v4/gcc-11.4.1/gcc/12.2.0-6frskzg/bin/g++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Checking whether system has ANSI C header files
-- Looking for 8 include files dlfcn.h, ..., float.h
-- Looking for 8 include files dlfcn.h, ..., float.h - found
-- Performing Test memchrExists
-- Performing Test memchrExists - Success
-- Performing Test freeExists
-- Performing Test freeExists - Success
-- ANSI C header files - found
-- Looking for include file unistd.h
-- Looking for include file unistd.h - found
-- Looking for DIR in sys/stat.h;sys/types.h;dirent.h
-- Looking for DIR in sys/stat.h;sys/types.h;dirent.h - found
-- Looking for stdio.h
-- Looking for stdio.h - found
-- Looking for math.h
-- Looking for math.h - found
-- Looking for errno.h
-- Looking for errno.h - found
-- Looking for stdarg.h
-- Looking for stdarg.h - found
-- Looking for sys/mman.h
-- Looking for sys/mman.h - found
-- Looking for sys/time.h
-- Looking for sys/time.h - found
-- Looking for fcntl.h
-- Looking for fcntl.h - found
-- Looking for sys/socket.h
-- Looking for sys/socket.h - found
-- Looking for netinet/in.h
-- Looking for netinet/in.h - found
-- Looking for netinet/tcp.h
-- Looking for netinet/tcp.h - found
-- Looking for arpa/inet.h
-- Looking for arpa/inet.h - found
-- Looking for limits.h
-- Looking for limits.h - found
-- Looking for pthread.h
-- Looking for pthread.h - found
-- Looking for signal.h
-- Looking for signal.h - found
-- Looking for getopt.h
-- Looking for getopt.h - found
-- Check size of long long
-- Check size of long long - done
-- Performing Test _have_inline
-- Performing Test _have_inline - Success
-- Performing Test _have_vla
-- Performing Test _have_vla - Success
-- Performing Test HAVE_INCOMPATIBLE_POINTER_TYPES
-- Performing Test HAVE_INCOMPATIBLE_POINTER_TYPES - Success
The 'gcem' submodule directory seems to be empty or incomplete. Attempting to download gcem from Github.
-- gcem source downloaded and extracted to /gpfs/scratch/abc123/fluidsynth-2.5.5/build/gcem-extracted
-- Found GCEM: /gpfs/scratch/abc123/fluidsynth-2.5.5/build/gcem-extracted/gcem-012ae73c6d0a2cb09ffe86475f5c6fba3926e200/include
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD - Success
-- Found Threads: TRUE
-- Found GLib2: /gpfs/scratch/abc123/spack-environments/spack-cmake/.spack-env/view/lib/libglib-2.0.so (found suitable version "2.78.3", minimum required is "2.6.5")
-- Could NOT find SndFileLegacy (missing: _sndfile_library SndFile_INCLUDE_DIR)
-- Could NOT find SndFile (Set SndFile_DIR to the directory containing its CMake config) (Required is at least version 1.0.0)
-- Could NOT find PulseAudio (Set PulseAudio_DIR to the directory containing its CMake config) (Required is at least version 2.0)
-- Could NOT find ALSA (missing: ALSA_LIBRARY ALSA_INCLUDE_DIR) (Required is at least version "0.9.1")
-- Could NOT find Jack (missing: Jack_LIBRARY Jack_INCLUDE_DIR)
-- Could NOT find PipeWire (missing: PipeWire_LIBRARY PipeWire_INCLUDE_DIR Spa_INCLUDE_DIR) (Required is at least version "0.3")
-- Could NOT find Systemd (missing: Systemd_LIBRARY Systemd_INCLUDE_DIR)
-- Found PkgConfig: /gpfs/scratch/abc123/spack-environments/spack-cmake/.spack-env/view/bin/pkg-config (found version "2.2.0")
-- Found DBus1: dbus-1
-- Looking for ladspa.h
-- Looking for ladspa.h - not found
-- Found Readline: /gpfs/scratch/abc123/spack-environments/spack-cmake/.spack-env/view/lib/libreadline.so (found version "8.2")
-- Looking for sys/soundcard.h
-- Looking for sys/soundcard.h - found
-- Looking for linux/soundcard.h
-- Looking for linux/soundcard.h - found
-- Looking for machine/soundcard.h
-- Looking for machine/soundcard.h - not found
-- Found OpenMP_C: -fopenmp (found version "4.5")
-- Found OpenMP: TRUE (found version "4.5") found components: C
-- Found OpenMP version: 4.5 date: 201511
-- Could NOT find InstPatch (missing: InstPatch_LIBRARY InstPatch_INCLUDE_DIR) (Required is at least version "1.1.0")
-- Looking for sinf
-- Looking for sinf - found
-- Looking for cosf
-- Looking for cosf - found
-- Looking for fabsf
-- Looking for fabsf - found
-- Looking for powf
-- Looking for powf - found
-- Looking for sqrtf
-- Looking for sqrtf - found
-- Looking for logf
-- Looking for logf - found
-- Looking for inet_ntop
-- Looking for inet_ntop - found
-- Check size of socklen_t
-- Check size of socklen_t - done
-- Could NOT find Doxygen (missing: DOXYGEN_EXECUTABLE)
--
**************************************************************
Build Summary:
FluidSynth Version: 2.5.5
Library version: 3.5.4
Git revision: not a git working copy
Build type: RelWithDebInfo
Install Prefix: /gpfs/scratch/abc123/fluidsynth-install
Audio / MIDI driver support:
ALSA: no
CoreAudio: no
CoreMIDI: no
DSound: no
JACK: no
MidiShare: no
Oboe: no
OpenSLES: no
OS/2 DART: no
OS/2 KAI: no
OSS: yes
PipeWire: no
PortAudio: no
PulseAudio: no
SDL3: no
WASAPI: no
WaveOut: no
WinMidi: no
Support for SF3 files: no (libsndfile not found)
Support for DLS files: yes
native: yes
libinstpatch: no
Audio to file rendering: yes
libsndfile: no (RAW PCM rendering only)
Miscellaneous support:
D-Bus: yes
LADSPA support: no
NETWORK Support: yes
IPV6 Support: yes
Readline: yes (NOTE: GPL library)
systemd: no
getopt: yes
Developer nerds info:
OS abstraction: glib
Samples type: double
Multithread rendering: yes
OpenMP 4.0: yes
Profiling: no
Debug Build: no
Trap on FPE (debug): no
Check FPE (debug): no
UBSan (debug): no
Coverage: no
**************************************************************
-- Configuring done (7.5s)
-- Generating done (0.9s)
-- Build files have been written to: /gpfs/scratch/abc123/fluidsynth-2.5.5/build
All required dependencies for the CMake command have been found and it has
run successfully. We can then go on to run the make all install command:
Installing FluidSynth with make all install (click to expand output)
[spack-cmake] $ make all install
[ 2%] Building C object src/CMakeFiles/libfluidsynth-OBJ.dir/drivers/fluid_aufile.c.o
[ 2%] Building C object src/CMakeFiles/libfluidsynth-OBJ.dir/bindings/fluid_rtkit.c.o
[ 5%] Building C object src/CMakeFiles/libfluidsynth-OBJ.dir/drivers/fluid_oss.c.o
[ 8%] Building CXX object src/CMakeFiles/libfluidsynth-OBJ.dir/sfloader/fluid_dls.cpp.o
[ 8%] Building C object src/CMakeFiles/libfluidsynth-OBJ.dir/utils/fluid_sys_glib.c.o
[ 11%] Building CXX object src/CMakeFiles/libfluidsynth-OBJ.dir/utils/fluid_file.cpp.o
[ 11%] Building CXX object src/CMakeFiles/libfluidsynth-OBJ.dir/gentables/fluid_ct2hz.cpp.o
[ 13%] Building CXX object src/CMakeFiles/libfluidsynth-OBJ.dir/gentables/fluid_cb2amp.cpp.o
[ 16%] Building CXX object src/CMakeFiles/libfluidsynth-OBJ.dir/gentables/fluid_concave.cpp.o
[ 16%] Building CXX object src/CMakeFiles/libfluidsynth-OBJ.dir/gentables/fluid_convex.cpp.o
[ 19%] Building CXX object src/CMakeFiles/libfluidsynth-OBJ.dir/gentables/fluid_pan.cpp.o
[ 22%] Building CXX object src/CMakeFiles/libfluidsynth-OBJ.dir/gentables/fluid_interp_coeff.cpp.o
[ 22%] Building CXX object src/CMakeFiles/libfluidsynth-OBJ.dir/gentables/fluid_interp_coeff_linear.cpp.o
[ 25%] Building CXX object src/CMakeFiles/libfluidsynth-OBJ.dir/gentables/fluid_interp_coeff_sinc7.cpp.o
[ 25%] Building C object src/CMakeFiles/libfluidsynth-OBJ.dir/utils/fluid_conv.c.o
[ 27%] Building C object src/CMakeFiles/libfluidsynth-OBJ.dir/utils/fluid_hash.c.o
[ 30%] Building C object src/CMakeFiles/libfluidsynth-OBJ.dir/utils/fluid_list.c.o
[ 30%] Building C object src/CMakeFiles/libfluidsynth-OBJ.dir/utils/fluid_ringbuffer.c.o
[ 33%] Building C object src/CMakeFiles/libfluidsynth-OBJ.dir/utils/fluid_settings.c.o
[ 36%] Building C object src/CMakeFiles/libfluidsynth-OBJ.dir/utils/fluid_sys.c.o
[ 36%] Building C object src/CMakeFiles/libfluidsynth-OBJ.dir/sfloader/fluid_defsfont.c.o
[ 38%] Building C object src/CMakeFiles/libfluidsynth-OBJ.dir/sfloader/fluid_sfont.c.o
[ 38%] Building C object src/CMakeFiles/libfluidsynth-OBJ.dir/sfloader/fluid_sffile.c.o
In file included from /gpfs/scratch/abc123/fluidsynth-2.5.5/src/synth/fluid_gen.h:24,
from /gpfs/scratch/abc123/fluidsynth-2.5.5/src/sfloader/fluid_sffile.h:27,
from /gpfs/scratch/abc123/fluidsynth-2.5.5/src/sfloader/fluid_sffile.c:24:
/gpfs/scratch/abc123/fluidsynth-2.5.5/src/utils/fluidsynth_priv.h: In function 'fluid_sffile_open':
/gpfs/scratch/abc123/fluidsynth-2.5.5/src/utils/fluidsynth_priv.h:328:38: warning: 'item.chr' may be used uninitialized [-Wmaybe-uninitialized]
328 | #define FLUID_LOG fluid_log
| ^~~~~~~~~
/gpfs/scratch/abc123/fluidsynth-2.5.5/src/sfloader/fluid_sffile.c:685:7: note: 'item.chr' was declared here
685 | } item;
| ^~~~
[ 41%] Building C object src/CMakeFiles/libfluidsynth-OBJ.dir/sfloader/fluid_samplecache.c.o
[ 44%] Building C object src/CMakeFiles/libfluidsynth-OBJ.dir/rvoice/fluid_adsr_env.c.o
[ 44%] Building C object src/CMakeFiles/libfluidsynth-OBJ.dir/rvoice/fluid_chorus.c.o
[ 47%] Building CXX object src/CMakeFiles/libfluidsynth-OBJ.dir/rvoice/fluid_iir_filter_impl.cpp.o
[ 50%] Building C object src/CMakeFiles/libfluidsynth-OBJ.dir/rvoice/fluid_iir_filter.c.o
[ 50%] Building C object src/CMakeFiles/libfluidsynth-OBJ.dir/rvoice/fluid_lfo.c.o
[ 52%] Building C object src/CMakeFiles/libfluidsynth-OBJ.dir/rvoice/fluid_rvoice.c.o
[ 52%] Building CXX object src/CMakeFiles/libfluidsynth-OBJ.dir/rvoice/fluid_rvoice_dsp.cpp.o
[ 55%] Building C object src/CMakeFiles/libfluidsynth-OBJ.dir/rvoice/fluid_rvoice_event.c.o
[ 58%] Building C object src/CMakeFiles/libfluidsynth-OBJ.dir/rvoice/fluid_rvoice_mixer.c.o
[ 58%] Building C object src/CMakeFiles/libfluidsynth-OBJ.dir/rvoice/fluid_rev.c.o
[ 61%] Building C object src/CMakeFiles/libfluidsynth-OBJ.dir/synth/fluid_chan.c.o
[ 63%] Building C object src/CMakeFiles/libfluidsynth-OBJ.dir/synth/fluid_event.c.o
[ 63%] Building C object src/CMakeFiles/libfluidsynth-OBJ.dir/synth/fluid_gen.c.o
[ 66%] Building C object src/CMakeFiles/libfluidsynth-OBJ.dir/synth/fluid_mod.c.o
[ 66%] Building C object src/CMakeFiles/libfluidsynth-OBJ.dir/synth/fluid_synth.c.o
[ 69%] Building C object src/CMakeFiles/libfluidsynth-OBJ.dir/synth/fluid_synth_monopoly.c.o
[ 72%] Building C object src/CMakeFiles/libfluidsynth-OBJ.dir/synth/fluid_tuning.c.o
[ 72%] Building C object src/CMakeFiles/libfluidsynth-OBJ.dir/synth/fluid_voice.c.o
[ 75%] Building C object src/CMakeFiles/libfluidsynth-OBJ.dir/midi/fluid_midi.c.o
/gpfs/scratch/abc123/fluidsynth-2.5.5/src/midi/fluid_midi.c: In function 'fluid_player_set_bpm':
/gpfs/scratch/abc123/fluidsynth-2.5.5/src/midi/fluid_midi.c:2577:5: warning: 'fluid_player_set_midi_tempo' is deprecated [-Wdeprecated-declarations]
2577 | return fluid_player_set_midi_tempo(player, 60000000L / bpm);
| ^~~~~~
/gpfs/scratch/abc123/fluidsynth-2.5.5/src/midi/fluid_midi.c:2554:5: note: declared here
2554 | int fluid_player_set_midi_tempo(fluid_player_t *player, int tempo)
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~
[ 77%] Building C object src/CMakeFiles/libfluidsynth-OBJ.dir/midi/fluid_midi_router.c.o
[ 77%] Building C object src/CMakeFiles/libfluidsynth-OBJ.dir/midi/fluid_seqbind.c.o
[ 80%] Building CXX object src/CMakeFiles/libfluidsynth-OBJ.dir/midi/fluid_seqbind_notes.cpp.o
[ 80%] Building C object src/CMakeFiles/libfluidsynth-OBJ.dir/midi/fluid_seq.c.o
[ 83%] Building CXX object src/CMakeFiles/libfluidsynth-OBJ.dir/midi/fluid_seq_queue.cpp.o
[ 86%] Building C object src/CMakeFiles/libfluidsynth-OBJ.dir/drivers/fluid_adriver.c.o
[ 86%] Building C object src/CMakeFiles/libfluidsynth-OBJ.dir/drivers/fluid_mdriver.c.o
[ 88%] Building C object src/CMakeFiles/libfluidsynth-OBJ.dir/bindings/fluid_cmd.c.o
[ 91%] Building C object src/CMakeFiles/libfluidsynth-OBJ.dir/bindings/fluid_filerenderer.c.o
[ 91%] Building C object src/CMakeFiles/libfluidsynth-OBJ.dir/bindings/fluid_ladspa.c.o
[ 91%] Built target libfluidsynth-OBJ
[ 94%] Linking CXX shared library libfluidsynth.so
[ 94%] Built target libfluidsynth
[ 97%] Building C object src/CMakeFiles/fluidsynth.dir/fluidsynth.c.o
[ 97%] Building CXX object src/CMakeFiles/fluidsynth.dir/utils/fluid_file.cpp.o
[100%] Linking CXX executable fluidsynth
[100%] Built target fluidsynth
Install the project...
-- Install configuration: "RelWithDebInfo"
-- Installing: /gpfs/scratch/abc123/fluidsynth-install/lib64/pkgconfig/fluidsynth.pc
-- Installing: /gpfs/scratch/abc123/fluidsynth-install/lib64/cmake/fluidsynth/FluidSynthConfig.cmake
-- Installing: /gpfs/scratch/abc123/fluidsynth-install/lib64/cmake/fluidsynth/FluidSynthConfigVersion.cmake
-- Installing: /gpfs/scratch/abc123/fluidsynth-install/bin/fluidsynth
-- Set non-toolchain portion of runtime path of "/gpfs/scratch/abc123/fluidsynth-install/bin/fluidsynth" to ""
-- Installing: /gpfs/scratch/abc123/fluidsynth-install/lib64/libfluidsynth.so.3.5.4
-- Installing: /gpfs/scratch/abc123/fluidsynth-install/lib64/libfluidsynth.so.3
-- Set non-toolchain portion of runtime path of "/gpfs/scratch/abc123/fluidsynth-install/lib64/libfluidsynth.so.3.5.4" to ""
-- Installing: /gpfs/scratch/abc123/fluidsynth-install/lib64/libfluidsynth.so
-- Installing: /gpfs/scratch/abc123/fluidsynth-install/include/fluidsynth/audio.h
-- Installing: /gpfs/scratch/abc123/fluidsynth-install/include/fluidsynth/event.h
-- Installing: /gpfs/scratch/abc123/fluidsynth-install/include/fluidsynth/gen.h
-- Installing: /gpfs/scratch/abc123/fluidsynth-install/include/fluidsynth/ladspa.h
-- Installing: /gpfs/scratch/abc123/fluidsynth-install/include/fluidsynth/log.h
-- Installing: /gpfs/scratch/abc123/fluidsynth-install/include/fluidsynth/midi.h
-- Installing: /gpfs/scratch/abc123/fluidsynth-install/include/fluidsynth/misc.h
-- Installing: /gpfs/scratch/abc123/fluidsynth-install/include/fluidsynth/mod.h
-- Installing: /gpfs/scratch/abc123/fluidsynth-install/include/fluidsynth/seq.h
-- Installing: /gpfs/scratch/abc123/fluidsynth-install/include/fluidsynth/seqbind.h
-- Installing: /gpfs/scratch/abc123/fluidsynth-install/include/fluidsynth/settings.h
-- Installing: /gpfs/scratch/abc123/fluidsynth-install/include/fluidsynth/sfont.h
-- Installing: /gpfs/scratch/abc123/fluidsynth-install/include/fluidsynth/shell.h
-- Installing: /gpfs/scratch/abc123/fluidsynth-install/include/fluidsynth/synth.h
-- Installing: /gpfs/scratch/abc123/fluidsynth-install/include/fluidsynth/types.h
-- Installing: /gpfs/scratch/abc123/fluidsynth-install/include/fluidsynth/voice.h
-- Installing: /gpfs/scratch/abc123/fluidsynth-install/include/fluidsynth/version.h
-- Installing: /gpfs/scratch/abc123/fluidsynth-install/include/fluidsynth.h
-- Installing: /gpfs/scratch/abc123/fluidsynth-install/lib64/cmake/fluidsynth/FluidSynth-shared-targets.cmake
-- Installing: /gpfs/scratch/abc123/fluidsynth-install/lib64/cmake/fluidsynth/FluidSynth-shared-targets-relwithdebinfo.cmake
-- Installing: /gpfs/scratch/abc123/fluidsynth-install/share/man/man1/fluidsynth.1
And your compiled application FluidSynth should now be available and run successfully:
Running FluidSynth
[spack-cmake] $ which fluidsynth
/gpfs/scratch/abc123/fluidsynth-install/bin/fluidsynth
[spack-cmake] $ fluidsynth --version
FluidSynth runtime version 2.5.5
Copyright (C) 2000-2026 Peter Hanappe and others.
Distributed under the LGPL license.
SoundFont(R) is a registered trademark of Creative Technology Ltd.
FluidSynth executable version 2.5.5
Sample type=double
In a job script or interactive job¶
Now that your environment is created, you can activate it and use it in a job script or interactive job with the following lines:
module load spack/<version>
spack env activate /gpfs/scratch/${USER}/spack-environments/spack-cmake
fluidsynth <command>
The -p flag is not required in job scripts because the decorated prompt will
not be observed within non-interactive jobs. The fluidsynth binary will be
available as long as you activate your Spack environment as part of the job
script or during the interactive job.