You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The way the AdsrEnvelope.h header is written, the specialized implementations for Linear and Exponential envelope types get defined multiple times when building a patch that uses a .cpp file, resulting in the Patch elf failing the linker step.
This is rather simple to reproduce just with two files implementing an empty Patch that just creates an AdsrEnvelope:
The result when compiling these is a linker error:
$ make PATCHNAME=EnvelopeBug clean patch
Building patch EnvelopeBug
/usr/lib/gcc/arm-none-eabi/12.2.0/../../../../arm-none-eabi/bin/ld: ./Build/PatchProgram.o (symbol from plugin): in function `onMidiCallback(unsigned char, unsigned char, unsigned char, unsigned char)':
(.text+0x0): multiple definition of `AdsrEnvelope<true>::increment(float, float)'; ./Build/EnvelopeBugPatch.o (symbol from plugin):(.text+0x0): first defined here
/usr/lib/gcc/arm-none-eabi/12.2.0/../../../../arm-none-eabi/bin/ld: ./Build/PatchProgram.o (symbol from plugin): in function `onMidiCallback(unsigned char, unsigned char, unsigned char, unsigned char)':
(.text+0x0): multiple definition of `AdsrEnvelope<true>::decrement(float, float)'; ./Build/EnvelopeBugPatch.o (symbol from plugin):(.text+0x0): first defined here
/usr/lib/gcc/arm-none-eabi/12.2.0/../../../../arm-none-eabi/bin/ld: ./Build/PatchProgram.o (symbol from plugin): in function `onMidiCallback(unsigned char, unsigned char, unsigned char, unsigned char)':
(.text+0x0): multiple definition of `AdsrEnvelope<false>::increment(float, float)'; ./Build/EnvelopeBugPatch.o (symbol from plugin):(.text+0x0): first defined here
/usr/lib/gcc/arm-none-eabi/12.2.0/../../../../arm-none-eabi/bin/ld: ./Build/PatchProgram.o (symbol from plugin): in function `onMidiCallback(unsigned char, unsigned char, unsigned char, unsigned char)':
(.text+0x0): multiple definition of `AdsrEnvelope<false>::decrement(float, float)'; ./Build/EnvelopeBugPatch.o (symbol from plugin):(.text+0x0): first defined here
/usr/lib/gcc/arm-none-eabi/12.2.0/../../../../arm-none-eabi/bin/ld: ./Build/PatchProgram.o (symbol from plugin): in function `onMidiCallback(unsigned char, unsigned char, unsigned char, unsigned char)':
(.text+0x0): multiple definition of `AdsrEnvelope<true>::calculateIncrement(float, float, float)'; ./Build/EnvelopeBugPatch.o (symbol from plugin):(.text+0x0): first defined here
/usr/lib/gcc/arm-none-eabi/12.2.0/../../../../arm-none-eabi/bin/ld: ./Build/PatchProgram.o (symbol from plugin): in function `onMidiCallback(unsigned char, unsigned char, unsigned char, unsigned char)':
(.text+0x0): multiple definition of `AdsrEnvelope<false>::calculateIncrement(float, float, float)'; ./Build/EnvelopeBugPatch.o (symbol from plugin):(.text+0x0): first defined here
/usr/lib/gcc/arm-none-eabi/12.2.0/../../../../arm-none-eabi/bin/ld: ./Build/PatchProgram.o (symbol from plugin): in function `onMidiCallback(unsigned char, unsigned char, unsigned char, unsigned char)':
(.text+0x0): multiple definition of `AdsrEnvelope<false>::MINLEVEL'; ./Build/EnvelopeBugPatch.o (symbol from plugin):(.text+0x0): first defined here
/usr/lib/gcc/arm-none-eabi/12.2.0/../../../../arm-none-eabi/bin/ld: ./Build/PatchProgram.o (symbol from plugin): in function `onMidiCallback(unsigned char, unsigned char, unsigned char, unsigned char)':
(.text+0x0): multiple definition of `AdsrEnvelope<true>::MINLEVEL'; ./Build/EnvelopeBugPatch.o (symbol from plugin):(.text+0x0): first defined here
/usr/lib/gcc/arm-none-eabi/12.2.0/../../../../arm-none-eabi/bin/ld: warning: Build/patch.elf has a LOAD segment with RWX permissions
collect2: error: ld returned 1 exit status
make[1]: *** [compile.mk:179: Build/patch.elf] Error 1
make: *** [Makefile:110: patch] Error 2
The text was updated successfully, but these errors were encountered:
This fixes the linker issue where multiple definitions are present for
the specialized AdsrEnvelope functions, by moving these specialized
functions into a new .cpp file.
Because these are specialized for specific types, they shouldn't be
included in multiple source files.
Tested using the repro steps in issue RebelTechnology#118.
There are 2 correct ways to use fully specialiazed templates - either in source file as described here, or keep them in the header file with inline keyword added. Moving them to a CPP file is probably preferable, as this would compile them just once when building static OWL library.
The way the AdsrEnvelope.h header is written, the specialized implementations for Linear and Exponential envelope types get defined multiple times when building a patch that uses a .cpp file, resulting in the Patch elf failing the linker step.
This is rather simple to reproduce just with two files implementing an empty Patch that just creates an AdsrEnvelope:
EnvelopeBugPatch.hpp
EnvelopeBugPatch.cpp
The result when compiling these is a linker error:
The text was updated successfully, but these errors were encountered: