DISTRHO / DPF

DISTRHO Plugin Framework
ISC License
672 stars 97 forks source link

Cannot build monolithic (2 in 1) LV2 plugin #406

Closed AnClark closed 1 year ago

AnClark commented 1 year ago

Hi, falkTX!

By now DPF only supports build separated LV2 plugin. When I try to build a monolithic one (DSP and UI part reside in the same binary), linker error will occur.

For example, I try to build the example states, and modify Makefile:

diff --git a/examples/States/Makefile b/examples/States/Makefile
index 3843faf5..21a8c753 100644
--- a/examples/States/Makefile
+++ b/examples/States/Makefile
@@ -27,7 +27,7 @@ include ../../Makefile.plugins.mk
 # Enable all possible plugin types

 TARGETS += jack
-TARGETS += lv2_sep
+TARGETS += lv2
 TARGETS += vst2
 TARGETS += vst3
 TARGETS += clap

Then make. At this time, linker error occurs:

Compiling ExamplePluginStates.cpp
Compiling ExampleUIStates.cpp
Compiling DistrhoPluginMain.cpp (LV2)
Compiling DistrhoUIMain.cpp (LV2)
Creating LV2 plugin for d_states
/usr/bin/ld: ../../build/d_states/DistrhoUIMain_LV2.cpp.o: in function `DISTRHO::getBinaryFilename()':
DistrhoUIMain.cpp:(.text._ZN7DISTRHO17getBinaryFilenameEv+0x0): multiple definition of `DISTRHO::getBinaryFilename()'; ../../build/d_states/DistrhoPluginMain_LV2.cpp.o:DistrhoPluginMain.cpp:(.text._ZN7DISTRHO17getBinaryFilenameEv+0x0): first defined here
/usr/bin/ld: ../../build/d_states/DistrhoUIMain_LV2.cpp.o: in function `DISTRHO::getPluginFormatName()':
DistrhoUIMain.cpp:(.text._ZN7DISTRHO19getPluginFormatNameEv+0x0): multiple definition of `DISTRHO::getPluginFormatName()'; ../../build/d_states/DistrhoPluginMain_LV2.cpp.o:DistrhoPluginMain.cpp:(.text._ZN7DISTRHO19getPluginFormatNameEv+0x0): first defined here
/usr/bin/ld: ../../build/d_states/DistrhoUIMain_LV2.cpp.o: in function `DISTRHO::getResourcePath(char const*)':
DistrhoUIMain.cpp:(.text._ZN7DISTRHO15getResourcePathEPKc+0x0): multiple definition of `DISTRHO::getResourcePath(char const*)'; ../../build/d_states/DistrhoPluginMain_LV2.cpp.o:DistrhoPluginMain.cpp:(.text._ZN7DISTRHO15getResourcePathEPKc+0x0): first defined here
/usr/bin/ld: ../../build/d_states/DistrhoUIMain_LV2.cpp.o: in function `DISTRHO::isUsingNativeAudio()':
DistrhoUIMain.cpp:(.text._ZN7DISTRHO18isUsingNativeAudioEv+0x0): multiple definition of `DISTRHO::isUsingNativeAudio()'; ../../build/d_states/DistrhoPluginMain_LV2.cpp.o:DistrhoPluginMain.cpp:(.text._ZN7DISTRHO18isUsingNativeAudioEv+0x0): first defined here
/usr/bin/ld: ../../build/d_states/DistrhoUIMain_LV2.cpp.o: in function `DISTRHO::supportsAudioInput()':
DistrhoUIMain.cpp:(.text._ZN7DISTRHO18supportsAudioInputEv+0x0): multiple definition of `DISTRHO::supportsAudioInput()'; ../../build/d_states/DistrhoPluginMain_LV2.cpp.o:DistrhoPluginMain.cpp:(.text._ZN7DISTRHO18supportsAudioInputEv+0x0): first defined here
/usr/bin/ld: ../../build/d_states/DistrhoUIMain_LV2.cpp.o: in function `DISTRHO::supportsBufferSizeChanges()':
DistrhoUIMain.cpp:(.text._ZN7DISTRHO25supportsBufferSizeChangesEv+0x0): multiple definition of `DISTRHO::supportsBufferSizeChanges()'; ../../build/d_states/DistrhoPluginMain_LV2.cpp.o:DistrhoPluginMain.cpp:(.text._ZN7DISTRHO25supportsBufferSizeChangesEv+0x0): first defined here
/usr/bin/ld: ../../build/d_states/DistrhoUIMain_LV2.cpp.o: in function `DISTRHO::supportsMIDI()':
DistrhoUIMain.cpp:(.text._ZN7DISTRHO12supportsMIDIEv+0x0): multiple definition of `DISTRHO::supportsMIDI()'; ../../build/d_states/DistrhoPluginMain_LV2.cpp.o:DistrhoPluginMain.cpp:(.text._ZN7DISTRHO12supportsMIDIEv+0x0): first defined here
/usr/bin/ld: ../../build/d_states/DistrhoUIMain_LV2.cpp.o: in function `DISTRHO::isAudioInputEnabled()':
DistrhoUIMain.cpp:(.text._ZN7DISTRHO19isAudioInputEnabledEv+0x0): multiple definition of `DISTRHO::isAudioInputEnabled()'; ../../build/d_states/DistrhoPluginMain_LV2.cpp.o:DistrhoPluginMain.cpp:(.text._ZN7DISTRHO19isAudioInputEnabledEv+0x0): first defined here
/usr/bin/ld: ../../build/d_states/DistrhoUIMain_LV2.cpp.o: in function `DISTRHO::isMIDIEnabled()':
DistrhoUIMain.cpp:(.text._ZN7DISTRHO13isMIDIEnabledEv+0x0): multiple definition of `DISTRHO::isMIDIEnabled()'; ../../build/d_states/DistrhoPluginMain_LV2.cpp.o:DistrhoPluginMain.cpp:(.text._ZN7DISTRHO13isMIDIEnabledEv+0x0): first defined here
/usr/bin/ld: ../../build/d_states/DistrhoUIMain_LV2.cpp.o: in function `DISTRHO::getBufferSize()':
DistrhoUIMain.cpp:(.text._ZN7DISTRHO13getBufferSizeEv+0x0): multiple definition of `DISTRHO::getBufferSize()'; ../../build/d_states/DistrhoPluginMain_LV2.cpp.o:DistrhoPluginMain.cpp:(.text._ZN7DISTRHO13getBufferSizeEv+0x0): first defined here
/usr/bin/ld: ../../build/d_states/DistrhoUIMain_LV2.cpp.o: in function `DISTRHO::requestAudioInput()':
DistrhoUIMain.cpp:(.text._ZN7DISTRHO17requestAudioInputEv+0x0): multiple definition of `DISTRHO::requestAudioInput()'; ../../build/d_states/DistrhoPluginMain_LV2.cpp.o:DistrhoPluginMain.cpp:(.text._ZN7DISTRHO17requestAudioInputEv+0x0): first defined here
/usr/bin/ld: ../../build/d_states/DistrhoUIMain_LV2.cpp.o: in function `DISTRHO::requestBufferSizeChange(unsigned int)':
DistrhoUIMain.cpp:(.text._ZN7DISTRHO23requestBufferSizeChangeEj+0x0): multiple definition of `DISTRHO::requestBufferSizeChange(unsigned int)'; ../../build/d_states/DistrhoPluginMain_LV2.cpp.o:DistrhoPluginMain.cpp:(.text._ZN7DISTRHO23requestBufferSizeChangeEj+0x0): first defined here
/usr/bin/ld: ../../build/d_states/DistrhoUIMain_LV2.cpp.o: in function `DISTRHO::requestMIDI()':
DistrhoUIMain.cpp:(.text._ZN7DISTRHO11requestMIDIEv+0x0): multiple definition of `DISTRHO::requestMIDI()'; ../../build/d_states/DistrhoPluginMain_LV2.cpp.o:DistrhoPluginMain.cpp:(.text._ZN7DISTRHO11requestMIDIEv+0x0): first defined here
collect2: error: ld returns 1
make: *** [../../Makefile.plugins.mk:504: ../../bin/d_states.lv2/d_states.so] Error 1

I see VST2/VST3/CLAP has similar Makefile rules. They can successfully build DSP and UI together. But only LV2 has this issue.

falkTX commented 1 year ago

pretty sure this works fine already, Cardinal, ProM and other plugins use this. if you changed this after building just clean and rebuild things again.

AnClark commented 1 year ago

Have you ever tested in examples bundled with DPF?

falkTX commented 1 year ago

not sure how it would be any different from e.g. https://github.com/DISTRHO/glBars/blob/master/plugins/glBars/Makefile

AnClark commented 1 year ago

Tested in a fresh clone of DPF source tree (Rev 03c3616), and compile example "States", problem still occurs.

glBars can build without errors. I wonder where the differences are.

falkTX commented 1 year ago

right, I know. glbars defines DISTRHO_PLUGIN_WANT_DIRECT_ACCESS to 1, while states example does not. with that flag dpf knows to build some extra bits only once.

I can make this more robust by detecting such build type, but it is still not recommended because we would then have DSP and UI on the same object/DLL file.

AnClark commented 1 year ago

My SynthV1 port also set this macro to 1, and problem also occurs there.

falkTX commented 1 year ago

it should be a slightly different error then.. or maybe related to it using external-ui. need to check this..

AnClark commented 1 year ago

The linker error mainly resides in "multiple definition". Maybe there's something to do with DistrhoMain.cpp or DistrhoPluginLV2.cpp?


EDIT: SynthV1 monolithic issue has been solved by clean-rebuild. (I only use CMake there.)

But issue still exists in example "States", "Info", and possibly other projects.