Undefined reference to FLAC and vorbis when running makefile

Hello there,

I’ve decided to start transitioning to using Cmake as I’ve begun daily driving Linux but I’m quite a beginner at it.

I’ve currently just started trying out compiling the example AudioPlugin in JUCE/examples/CMake, but I’ve had almost no luck with it. I’ve managed to get the build tree up and running, but when I run the actual makefile, it starts for a bit and then crashes. Some snippets of the error message include

juce_audio_formats.cpp:(.text._ZN4juce10FlacReaderC2EPNS_11InputStreamE[_ZN4juce10FlacReaderC5EPNS_11InputStreamE]+0xb0): undefined reference to `FLAC__stream_decoder_new’

and

juce_audio_formats.cpp:(.text._ZN4juce9OggWriterC2EPNS_12OutputStreamEdjjiRKNS_15StringPairArrayE[_ZN4juce9OggWriterC5EPNS_12OutputStreamEdjjiRKNS_15StringPairArrayE]+0xd6): undefined reference to `vorbis_info_init’

I think I’m missing some sort of FLAC and OGG modules. I’ve tried installing FLAC through apt, but the error still remains.

As I said, I’m a beginner with CMake, so this is what I have for my top-level CMakeLists.txt. I’ve tried following the API documentation as closely as possible, but I still feel a little confused by it.

cmake_minimum_required(VERSION 3.22)
project(TestCMake VERSION 1.0.0)
find_package(JUCE CONFIG REQUIRED)
add_subdirectory(AudioPlugin)

It’s quite frustrating having to struggle with the build process, so any help at this point would be great appreciated.

Thanks.

Okay, let’s find out how this works. At first you make a project folder and enter it:

mkdir myplugin && cd myplugin

clone the juce framework with git.

git clone https://github.com/juce-framework/JUCE.git

Now copy the cmake audio plug-in example to your project folder:

cp JUCE/examples/CMake/AudioPlugin/* .

Edit the CmakeLists.txt and uncomment line 26, so cmake will find juce.

Make a build folder and enter it:

mkdir build && cd build

Now you should be able to build the project:

cmake ..
make

This is only a starting point and should give you a idea of how this works.

Thanks for the specific line number. I missed it the first time around cause most of the cmake file was just comments. I’ve gotten this working with the global path as well.

Cheers.