Linux/debian builds fail

Hi, im trying to build my audio plugin on debian trixie using something like:

sudo apt install \
  cmake \
  libx11-dev \
  libxrandr-dev \
  libxinerama-dev \
  libxcursor-dev \
  libxft-dev \
  libxi-dev \
  libvorbis-dev \
  libflac-dev \
  juce-modules-source
git clone <my-audio-plugin>
cd <my-audio-plugin>
cmake -B build .
cmake --build build

But around 60% I get:

 60%] Linking CXX executable <audio-plugin>_artefacts/Standalone/<audio-plugin>

/usr/bin/ld: <audio-plugin>_artefacts/lib<audio-plugin>_SharedCode.a(juce_audio_formats.cpp.o): in
 function `juce::FlacReader::FlacReader(juce::InputStream*)':
juce_audio_formats.cpp:(.text._ZN4juce10FlacReaderC2EPNS_11InputStreamE[_ZN4juce10Fl
acReaderC5EPNS_11InputStreamE]+0x9d): undefined reference to `FLAC__stream_decoder_n
ew'
/usr/bin/ld: juce_audio_formats.cpp:(.text._ZN4juce10FlacReaderC2EPNS_11InputStreamE
[_ZN4juce10FlacReaderC5EPNS_11InputStreamE]+0xf6): undefined reference to `FLAC__str
eam_decoder_init_stream'
/usr/bin/ld: juce_audio_formats.cpp:(.text._ZN4juce10FlacReaderC2EPNS_11InputStreamE
[_ZN4juce10FlacReaderC5EPNS_11InputStreamE]+0x12c): undefined reference to `FLAC__st
ream_decoder_process_until_end_of_metadata'

Has anybody any clue on why that is? Im not using JUCE as a submodule but rather the find_package() function from the CMake API.

The official JUCE distribution comes with a bundled FLAC, but it’s not unlikely the Debian system package unbundles it and expects you to use the system shared FLAC. (Hence your installation of libflac-dev.) In which case, you may need to link with FLAC in your CMake configuration.

Assuming Debian’s libflac-dev includes CMake CONFIG files, like Fedora’s does, that’d be…

find_package(FLAC REQUIRED)
target_link_libraries(my_plugin PRIVATE FLAC::FLAC)

(Or maybe FLAC::FLAC++, but it looks like JUCE uses the C bindings for libflac even though it’s a C++ codebase.)

Thanks!
Didn’t work on debian because libflac-dev doesn’t include said cmake files but works on Arch Linux.

On Debian you’d want to use the flac.pc pkgconfig file that it surely does come bundled with, then. For example..

find_package(PkgConfig)
if(PkgConfig_FOUND)
  pkg_check_modules(FLAC flac IMPORTED_TARGET)
endif()
if(NOT TARGET PkgConfig::FLAC)
  message(FATAL_ERROR "libflac is required!")
endif()
target_link_libraries(my_plugin PRIVATE PkgConfig::FLAC)