[Solved] [CMake - Linux] Several undefined references to juce::OSCReceiver functions

Hi everyone,

I’m currently trying out developing an audio application using CMake for the first time. I managed to create a test class that just does a basic animation.So, as recommended on the GUI_APP_EXAMPLE I imported the juce_gui_extra.h file and it compiled right away. So then , I tried creating a new class that is able to receive OSC messages so i just imported the juce_gui_extra.h file as well as the juce_osc.h file. But it does not compile anymore, the output tells me that there are several undefined references to juce::OSCReceiver functions. I am surely doing something wrong there but i cannot put my finger on it.

Thank you for any help, I’m leaving you with the output and my OSCReceiver class file.

====================[ Build | GuiAppExample | Debug ]===========================
/app/extra/clion/bin/cmake/linux/x64/bin/cmake --build /home/clementone/Documents/DEVS/JUCE/GuiApp-test/cmake-build-debug --target GuiAppExample -j 6
[0/2] Re-checking globbed directories…
[4/4] Linking CXX executable “GuiAppExample_artefacts/Debug/Gui App Example”
FAILED: GuiAppExample_artefacts/Debug/Gui App Example
: && /usr/bin/c++ -g CMakeFiles/GuiAppExample.dir/Source/Main.cpp.o CMakeFiles/GuiAppExample.dir/Source/MainComponent.cpp.o CMakeFiles/GuiAppExample.dir/Source/test/test.cpp.o CMakeFiles/GuiAppExample.dir/Source/OSC/OSCReceiver.cpp.o CMakeFiles/GuiAppExample.dir/home/clementone/JUCE/modules/juce_gui_extra/juce_gui_extra.cpp.o CMakeFiles/GuiAppExample.dir/home/clementone/JUCE/modules/juce_gui_basics/juce_gui_basics.cpp.o CMakeFiles/GuiAppExample.dir/home/clementone/JUCE/modules/juce_graphics/juce_graphics.cpp.o CMakeFiles/GuiAppExample.dir/home/clementone/JUCE/modules/juce_events/juce_events.cpp.o CMakeFiles/GuiAppExample.dir/home/clementone/JUCE/modules/juce_core/juce_core.cpp.o CMakeFiles/GuiAppExample.dir/home/clementone/JUCE/modules/juce_data_structures/juce_data_structures.cpp.o -o “GuiAppExample_artefacts/Debug/Gui App Example” /usr/lib/x86_64-linux-gnu/libfreetype.so -lrt -ldl -lpthread && :
/usr/lib/gcc/x86_64-unknown-linux-gnu/12.2.0/…/…/…/…/x86_64-unknown-linux-gnu/bin/ld: CMakeFiles/GuiAppExample.dir/Source/OSC/OSCReceiver.cpp.o: attention: réadressage sur « _ZN4juce8OSCTypes7float32E » dans la section en lecture seule « .text._ZNK4juce11OSCArgument9isFloat32Ev[_ZNK4juce11OSCArgument9isFloat32Ev] »
/usr/lib/gcc/x86_64-unknown-linux-gnu/12.2.0/…/…/…/…/x86_64-unknown-linux-gnu/bin/ld : CMakeFiles/GuiAppExample.dir/Source/OSC/OSCReceiver.cpp.o : dans la fonction « OSCReceiver::OSCReceiver(int) » :
/home/clementone/Documents/DEVS/JUCE/GuiApp-test/Source/OSC/OSCReceiver.cpp:6 : référence indéfinie vers « juce::OSCReceiver::OSCReceiver() »
/usr/lib/gcc/x86_64-unknown-linux-gnu/12.2.0/…/…/…/…/x86_64-unknown-linux-gnu/bin/ld : /home/clementone/Documents/DEVS/JUCE/GuiApp-test/Source/OSC/OSCReceiver.cpp:16 : référence indéfinie vers « juce::OSCReceiver::connect(int) »
/usr/lib/gcc/x86_64-unknown-linux-gnu/12.2.0/…/…/…/…/x86_64-unknown-linux-gnu/bin/ld : /home/clementone/Documents/DEVS/JUCE/GuiApp-test/Source/OSC/OSCReceiver.cpp:19 : référence indéfinie vers « juce::OSCAddress::OSCAddress(char const*) »
/usr/lib/gcc/x86_64-unknown-linux-gnu/12.2.0/…/…/…/…/x86_64-unknown-linux-gnu/bin/ld : /home/clementone/Documents/DEVS/JUCE/GuiApp-test/Source/OSC/OSCReceiver.cpp:19 : référence indéfinie vers « juce::OSCReceiver::addListener(juce::OSCReceiver::ListenerWithOSCAddressjuce::OSCReceiver::MessageLoopCallback*, juce::OSCAddress) »
/usr/lib/gcc/x86_64-unknown-linux-gnu/12.2.0/…/…/…/…/x86_64-unknown-linux-gnu/bin/ld : /home/clementone/Documents/DEVS/JUCE/GuiApp-test/Source/OSC/OSCReceiver.cpp:23 : référence indéfinie vers « juce::OSCReceiver::~OSCReceiver() »
/usr/lib/gcc/x86_64-unknown-linux-gnu/12.2.0/…/…/…/…/x86_64-unknown-linux-gnu/bin/ld : CMakeFiles/GuiAppExample.dir/Source/OSC/OSCReceiver.cpp.o : dans la fonction « OSCReceiver::~OSCReceiver() » :
/home/clementone/Documents/DEVS/JUCE/GuiApp-test/Source/OSC/OSCReceiver.cpp:27 : référence indéfinie vers « juce::OSCReceiver::~OSCReceiver() »
/usr/lib/gcc/x86_64-unknown-linux-gnu/12.2.0/…/…/…/…/x86_64-unknown-linux-gnu/bin/ld : CMakeFiles/GuiAppExample.dir/Source/OSC/OSCReceiver.cpp.o : dans la fonction « OSCReceiver::oscMessageReceived(juce::OSCMessage const&) » :
/home/clementone/Documents/DEVS/JUCE/GuiApp-test/Source/OSC/OSCReceiver.cpp:30 : référence indéfinie vers « juce::OSCMessage::size() const »
/usr/lib/gcc/x86_64-unknown-linux-gnu/12.2.0/…/…/…/…/x86_64-unknown-linux-gnu/bin/ld : /home/clementone/Documents/DEVS/JUCE/GuiApp-test/Source/OSC/OSCReceiver.cpp:30 : référence indéfinie vers « juce::OSCMessage::operator const »
/usr/lib/gcc/x86_64-unknown-linux-gnu/12.2.0/…/…/…/…/x86_64-unknown-linux-gnu/bin/ld : /home/clementone/Documents/DEVS/JUCE/GuiApp-test/Source/OSC/OSCReceiver.cpp:31 : référence indéfinie vers « juce::OSCMessage::operator const »
/usr/lib/gcc/x86_64-unknown-linux-gnu/12.2.0/…/…/…/…/x86_64-unknown-linux-gnu/bin/ld : /home/clementone/Documents/DEVS/JUCE/GuiApp-test/Source/OSC/OSCReceiver.cpp:31 : référence indéfinie vers « juce::OSCArgument::getFloat32() const »
/usr/lib/gcc/x86_64-unknown-linux-gnu/12.2.0/…/…/…/…/x86_64-unknown-linux-gnu/bin/ld : CMakeFiles/GuiAppExample.dir/Source/OSC/OSCReceiver.cpp.o : dans la fonction « juce::OSCArgument::isFloat32() const » :
/home/clementone/JUCE/modules/juce_osc/osc/juce_OSCArgument.h:72 : référence indéfinie vers « juce::OSCTypes::float32 »
/usr/lib/gcc/x86_64-unknown-linux-gnu/12.2.0/…/…/…/…/x86_64-unknown-linux-gnu/bin/ld: attention: création de DT_TEXTREL dans un PIE
collect2: erreur: ld a retourné le statut de sortie 1
ninja: build stopped: subcommand failed.

OSCReceiver.cpp (1.2 KB)
OSCReceiver.h (1.0 KB)

In your CMakeLists.txt, in the target_link_libraries for your target, are you linking to juce_osc?

Thank you it worked ! Sorry to have bothered you for only this.