zachwieja / 2LiftStudios

2LiftStudios VCVRack Modules
GNU General Public License v3.0
2 stars 0 forks source link

Missing methods on base class fails to build with newer gcc compiler #2

Closed SteveRussell33 closed 1 year ago

SteveRussell33 commented 1 year ago

Hi, Tried to build locally (commented out svg in Makefile as Inkscape stage gave this error, even though I have it installed)

mkdir -p res/common/
cp src/res/common/TinyButtonDarkGray.svg res/common/
mkdir -p res/common/
cp src/res/common/TinyButtonGray.svg res/common/
mkdir -p res/common/
cp src/res/common/TinyButtonGreen.svg res/common/
mkdir -p res/common/
cp src/res/common/TinyButtonRed.svg res/common/
mkdir -p build/res/
mkdir -p build/res/
cp src/res/Comps.svg build/res/
cp src/res/Merge.svg build/res/
'/c/Inkscape/bin/inkscape.exe' -g --batch-process --actions='EditSelectAll;SelectionUnGroup;EditSelectAll;EditUnlinkClone;EditSelectAll;ObjectToPath;FileSave' build/res/Comps.svg
'/c/Inkscape/bin/inkscape.exe' -g --batch-process --actions='EditSelectAll;SelectionUnGroup;EditSelectAll;EditUnlinkClone;EditSelectAll;ObjectToPath;FileSave' build/res/Merge.svg
mkdir -p build/res/
cp src/res/ProbS.svg build/res/
'/c/Inkscape/bin/inkscape.exe' -g --batch-process --actions='EditSelectAll;SelectionUnGroup;EditSelectAll;EditUnlinkClone;EditSelectAll;ObjectToPath;FileSave' build/res/ProbS.svg
mkdir -p build/res/
cp src/res/Quant.svg build/res/
'/c/Inkscape/bin/inkscape.exe' -g --batch-process --actions='EditSelectAll;SelectionUnGroup;EditSelectAll;EditUnlinkClone;EditSelectAll;ObjectToPath;FileSave' build/res/Quant.svg
Failed to register: Timeout was reached
Failed to register: Timeout was reached
Failed to register: Timeout was reached
InkscapeApplication::parse_actions: could not find action for: EditSelectAll
InkscapeApplication::parse_actions: could not find action for: SelectionUnGroup
InkscapeApplication::parse_actions: could not find action for: EditSelectAll
InkscapeApplication::parse_actions: could not find action for: EditUnlinkClone
InkscapeApplication::parse_actions: could not find action for: EditSelectAll
InkscapeApplication::parse_actions: could not find action for: ObjectToPath
InkscapeApplication::parse_actions: could not find action for: FileSave
make: *** [Makefile:49: build/res/Merge.svg] Error 1
make: *** Waiting for unfinished jobs....
make: *** [Makefile:49: build/res/Comps.svg] Error 1
make: *** [Makefile:49: build/res/Quant.svg] Error 1
rm build/res/ProbS.svg build/res/Comps.svg build/res/Quant.svg build/res/Merge.svg

make dist then failed with this error

g++ -o plugin.dll build/src/plugin.cpp.o build/src/modules/Comps.cpp.o build/src/modules/Merge.cpp.o build/src/modules/ProbS.cpp.o build/src/modules/Quant.cpp.o build/src/modules/SandH.cpp.o build/src/modules/Split.cpp.o build/src/modules/Steps.cpp.o build/src/modules/VCASR.cpp.o build/src/common/Gate.cpp.o build/src/common/GateBase.cpp.o build/src/common/LcdDisplayWidget.cpp.o build/src/common/ManualGate.cpp.o build/src/common/Scale.cpp.o build/src/common/Settings.cpp.o build/src/common/Theme.cpp.o build/src/common/Themes.cpp.o build/src/common/Utilities.cpp.o -shared -L../.. -lRack -static-libstdc++
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/13.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: build/src/common/Gate.cpp.o:Gate.cpp:(.rdata$.refptr._ZTV8GateBase[.refptr._ZTV8GateBase]+0x0): undefined reference to `vtable for GateBase'
collect2.exe: error: ld returned 1 exit status
make: *** [../../compile.mk:79: plugin.dll] Error 1
zachwieja commented 1 year ago

Thanks Steve. I believe Inkscape changed the way it does batch command processing. I have been using v1.1.2. I need to find a new incantation for later versions. For now, all the .svg files are pre-built and available in the repository. Your commenting out the svg target works (as long as you aren't changing the source).

For the linkage problem, I did clean build without issue. I cloned the repository and built without issue. So it must be environmental.

  1. I am using SDK 2.1.2. But I just tested with 2.0.6 and 2.3.0. It builds just fine in both cases.
  2. That leaves the compiler? I have a May 2022 version of the MSYS2 tools with gcc v12.2 (lower than your 13.1)

I suspect I am doing something wrong in that class, and the new compiler is being more strict. I will need to install a new build environment for that (harder than adding an SDK). And will need to read some articles starting at https://stackoverflow.com/questions/3065154/undefined-reference-to-vtable

For now, I have removed the gate classes and the one module (VCASR - combined VCA and ASR envelope) that used those gate classes. This builds and runs for me on all the same combinations I mention above, but ... I don't have your combination.

SteveRussell33 commented 1 year ago

Understood, thanks for the reply. I'll check out that SO article later as I'm still not up with C++ OOP and will use this as a learning experience.

Keeping MSYS up to date is something I do at least once a week by using pacman -Syuu so that's why I'm on GCC v13. I also have undated Inkscape to the latest v1.3 as it was starting to lag using it on my machine.

If I come up with a fix, I'll note it here and may do a PR if successful.

SteveRussell33 commented 1 year ago

Hi Stephan, Having read the SO article I've fixed this:

I added void GateBase::process() {} to GateBase.cpp as it's the only member function that wasn't defined.

Build success! (This works with GCC v13.2 - updated today)

g++ -std=c++11 -Wsuggest-override  -Isrc -Isrc/common -Isrc/components -fPIC -I../../include -I../../dep/include -MMD -MP -g -Og -funsafe-math-optimizations -fno-omit-frame-pointer -Wall -Wextra -Wno-unused-parameter -DARCH_X64 -march=nehalem -DARCH_WIN -D_USE_MATH_DEFINES -municode  -c -o build/src/common/GateBase.cpp.o src/common/GateBase.cpp
g++ -o plugin.dll build/src/plugin.cpp.o build/src/modules/Comps.cpp.o build/src/modules/Merge.cpp.o build/src/modules/ProbS.cpp.o build/src/modules/Quant.cpp.o build/src/modules/SandH.cpp.o build/src/modules/Split.cpp.o build/src/modules/Steps.cpp.o build/src/modules/VCASR.cpp.o build/src/common/Gate.cpp.o build/src/common/GateBase.cpp.o build/src/common/LcdDisplayWidget.cpp.o build/src/common/ManualGate.cpp.o build/src/common/Scale.cpp.o build/src/common/Settings.cpp.o build/src/common/Theme.cpp.o build/src/common/Themes.cpp.o build/src/common/Utilities.cpp.o -shared -L../.. -lRack -static-libstdc++
rm -rf dist
mkdir -p dist/2LiftStudios
cp plugin.dll dist/2LiftStudios/
strip -s dist/2LiftStudios/plugin.dll
cp -r --parents res/common res/dark res/light LICENSE presets plugin.json dist/2LiftStudios/
cd dist && tar -c 2LiftStudios | zstd -19 -o "2LiftStudios"-"2.0.0"-win-x64.vcvplugin
/*stdin*\            : 14.38%   (  1.15 MiB =>    170 KiB, 2LiftStudios-2.0.0-win-x64.vcvplugin)
zachwieja commented 1 year ago

Thanks Steve. I get, now, why those are required. I will have to read up to see if C++ has the concept of abstract methods, where the base class does not have an implementation, which forces the dependent classes to add one.

All checked-in. Thanks to you in the comments. I tried to add you as co-author but it didn't take (maybe because you aren't a part of the project).

SteveRussell33 commented 1 year ago

No worries, glad to help.

On the last point I think you have to add someone as a contributor, not 100% on that though.

I'll close this now.