Tracktion/tracktion_engine

EngineInPluginDemo build fails on Linux: undefined reference to `src_callback_new' (libsamplerate)

Closed this issue · 8 comments

Hello,
I'm trying to build the EngineInPluginDemo example on Linux using CLion and getting error related to functions from libsamplerate that is included in the repository. src_callback_new, src_delete, src_rest, src_callback read.
In the IDE, clicking on the function name (for example, at tracktion_WaveNode.cpp:308) leads me to its definition in samplerate.h - but for some reason the build fails here.
I will appreciate your help on this.

Thanks,
Jonathan

Full build output is here:
====================[ Build | EngineInPluginDemo_LV2 | Debug ]================== /home/jonathan/Applications/clion-2023.1.2/bin/cmake/linux/x64/bin/cmake --build /home/jonathan/dev/tracktion_engine/examples/EngineInPluginDemo/cmake-build-debug --target EngineInPluginDemo_LV2 -j 3 [0/2] Re-checking globbed directories... [10/10] Linking CXX shared module EngineInPluginDemo_artefacts/Debug/LV2/EngineInPluginDemo.lv2/libEngineInPluginDemo.so FAILED: EngineInPluginDemo_artefacts/Debug/LV2/EngineInPluginDemo.lv2/libEngineInPluginDemo.so : && /usr/bin/c++ -fPIC -Wno-unknown-pragmas -g -Wl,--no-undefined -shared -o EngineInPluginDemo_artefacts/Debug/LV2/EngineInPluginDemo.lv2/libEngineInPluginDemo.so CMakeFiles/EngineInPluginDemo_LV2.dir/home/jonathan/dev/tracktion_engine/modules/juce/modules/juce_audio_plugin_client/juce_audio_plugin_client_AAX.cpp.o CMakeFiles/EngineInPluginDemo_LV2.dir/home/jonathan/dev/tracktion_engine/modules/juce/modules/juce_audio_plugin_client/juce_audio_plugin_client_ARA.cpp.o CMakeFiles/EngineInPluginDemo_LV2.dir/home/jonathan/dev/tracktion_engine/modules/juce/modules/juce_audio_plugin_client/juce_audio_plugin_client_LV2.cpp.o CMakeFiles/EngineInPluginDemo_LV2.dir/home/jonathan/dev/tracktion_engine/modules/juce/modules/juce_audio_plugin_client/juce_audio_plugin_client_Standalone.cpp.o CMakeFiles/EngineInPluginDemo_LV2.dir/home/jonathan/dev/tracktion_engine/modules/juce/modules/juce_audio_plugin_client/juce_audio_plugin_client_Unity.cpp.o CMakeFiles/EngineInPluginDemo_LV2.dir/home/jonathan/dev/tracktion_engine/modules/juce/modules/juce_audio_plugin_client/juce_audio_plugin_client_VST2.cpp.o CMakeFiles/EngineInPluginDemo_LV2.dir/home/jonathan/dev/tracktion_engine/modules/juce/modules/juce_audio_plugin_client/juce_audio_plugin_client_VST3.cpp.o EngineInPluginDemo_artefacts/Debug/libEngineInPluginDemo_SharedCode.a /usr/lib/libcurl.so /usr/lib/libwebkit2gtk-4.0.so /usr/lib/libsoup-2.4.so /usr/lib/libgmodule-2.0.so /usr/lib/libglib-2.0.so /usr/lib/libjavascriptcoregtk-4.0.so /usr/lib/libgtk-3.so /usr/lib/libgdk-3.so /usr/lib/libz.so /usr/lib/libpangocairo-1.0.so /usr/lib/libpango-1.0.so /usr/lib/libharfbuzz.so /usr/lib/libatk-1.0.so /usr/lib/libcairo-gobject.so /usr/lib/libcairo.so /usr/lib/libgdk_pixbuf-2.0.so /usr/lib/libgio-2.0.so /usr/lib/libgobject-2.0.so /usr/lib/libglib-2.0.so /usr/lib/libjavascriptcoregtk-4.0.so /usr/lib/libgtk-3.so /usr/lib/libgdk-3.so /usr/lib/libz.so /usr/lib/libpangocairo-1.0.so /usr/lib/libpango-1.0.so /usr/lib/libharfbuzz.so /usr/lib/libatk-1.0.so /usr/lib/libcairo-gobject.so /usr/lib/libcairo.so /usr/lib/libgdk_pixbuf-2.0.so /usr/lib/libgio-2.0.so /usr/lib/libgobject-2.0.so /usr/lib/libasound.so /usr/lib/libfreetype.so -lrt -ldl -lpthread -latomic && cd /home/jonathan/dev/tracktion_engine/examples/EngineInPluginDemo/cmake-build-debug && /home/jonathan/dev/tracktion_engine/examples/EngineInPluginDemo/cmake-build-debug/juce_lv2_helper /home/jonathan/dev/tracktion_engine/examples/EngineInPluginDemo/cmake-build-debug/EngineInPluginDemo_artefacts/Debug/LV2/EngineInPluginDemo.lv2/libEngineInPluginDemo.so /usr/bin/ld: EngineInPluginDemo_artefacts/Debug/libEngineInPluginDemo_SharedCode.a(tracktion_engine_playback.cpp.o): in function 'tracktion::engine::HighQualityResamplerReader::HighQualityResamplerReader(std::unique_ptr<tracktion::core::AudioReader, std::default_delete<tracktion::core::AudioReader> >, double, tracktion::engine::ResamplingQuality)': /home/jonathan/dev/tracktion_engine/modules/tracktion_engine/playback/graph/tracktion_WaveNode.cpp:308: undefined reference to 'src_callback_new' /usr/bin/ld: EngineInPluginDemo_artefacts/Debug/libEngineInPluginDemo_SharedCode.a(tracktion_engine_playback.cpp.o): in function 'tracktion::engine::HighQualityResamplerReader::~HighQualityResamplerReader()': /home/jonathan/dev/tracktion_engine/modules/tracktion_engine/playback/graph/tracktion_WaveNode.cpp:315: undefined reference to 'src_delete' /usr/bin/ld: EngineInPluginDemo_artefacts/Debug/libEngineInPluginDemo_SharedCode.a(tracktion_engine_playback.cpp.o): in function 'tracktion::engine::HighQualityResamplerReader::setPosition(long)': /home/jonathan/dev/tracktion_engine/modules/tracktion_engine/playback/graph/tracktion_WaveNode.cpp:332: undefined reference to 'src_reset' /usr/bin/ld: EngineInPluginDemo_artefacts/Debug/libEngineInPluginDemo_SharedCode.a(tracktion_engine_playback.cpp.o): in function 'tracktion::engine::HighQualityResamplerReader::readChunk(choc::buffer::BufferView<float, choc::buffer::SeparateChannelLayout> const&)': /home/jonathan/dev/tracktion_engine/modules/tracktion_engine/playback/graph/tracktion_WaveNode.cpp:446: undefined reference to 'src_callback_read' collect2: error: ld returned 1 exit status ninja: build stopped: subcommand failed.

FigBug commented

You need to define TRACKTION_BUILD_LIBSAMPLERATE if you want to use the included copy of libsamplerate.

You need to define TRACKTION_BUILD_LIBSAMPLERATE if you want to use the included copy of libsamplerate.

By the code in tracktion_engine.h it seems that it is on by default:
#ifndef TRACKTION_BUILD_LIBSAMPLERATE #define TRACKTION_BUILD_LIBSAMPLERATE 1 #endif

I also defined it again in the cmake file but the issue persists.

FigBug commented

Do you have the package for libsamplerate installed on your Linux machine? If so, then you should just need to add the name of the library to your linker flags.

Hmm, you shouldn't need to set TRACKTION_BUILD_LIBSAMPLERATE or link to it by default. That option is really just for disabling the internal copy in case you use it elsewhere in your code and want to avoid ODR violations.

Can you try just building the stand-alone target and see if that works. I'm not sure if we have CI for the LV2 target yet as its relatively new to JUCE.

Hmm, you shouldn't need to set TRACKTION_BUILD_LIBSAMPLERATE or link to it by default. That option is really just for disabling the internal copy in case you use it elsewhere in your code and want to avoid ODR violations.

I thought so, because all reference to samplerate.h are with relative path to 3rd_party folder.

Tried now to build the standalone target and getting the same error (develop branch). I tried before VST3 and LV2 targets.

FigBug commented

I think the issue is here:

#if __has_include(<samplerate.h>)
 #include <samplerate.h>
#else

If <samplerate.h> is in your include path, then it skips using the build in version.

FigBug commented

I've made some changes, can you try again now, it should "just work"