Tracktion / tracktion_engine

Tracktion Engine module
Other
1.16k stars 148 forks source link

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

Closed jony543 closed 1 year ago

jony543 commented 1 year ago

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 1 year ago

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

jony543 commented 1 year ago

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 1 year ago

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.

drowaudio commented 1 year ago

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.

jony543 commented 1 year ago

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 1 year ago

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 1 year ago

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

jony543 commented 1 year ago

I was about to write that it was bingo and I should have thought about it. Removed that if and now it compiles. Will check the event changes later. Thanks for your help!


From: Roland Rabien @.> Sent: Wednesday, May 10, 2023 11:32:30 AM To: Tracktion/tracktion_engine @.> Cc: Jonathan A. @.>; Author @.> Subject: Re: [Tracktion/tracktion_engine] EngineInPluginDemo build fails on Linux: undefined reference to `src_callback_new' (libsamplerate) (Issue #153)

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

— Reply to this email directly, view it on GitHubhttps://github.com/Tracktion/tracktion_engine/issues/153#issuecomment-1542414644, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AA7MOCW4REYAZ3FU7UOLO6TXFOYI5ANCNFSM6AAAAAAX4BAH2E. You are receiving this because you authored the thread.Message ID: @.***>