davetcc / tcMenu

Menu library for Arduino, mbed and ESP with designer UI and remote control capabilities.
https://www.thecoderscorner.com/products/arduino-libraries/tc-menu/
Apache License 2.0
272 stars 25 forks source link

using DarkModeTraditional with eTFT and seperated generated source files creates invalid include #362

Closed emaayan closed 11 months ago

emaayan commented 1 year ago

(using tcLib menu v4) To Reproduce select "Project in src folder / seperate generated fodler " select TFT_eSPI display select Dark Mode tradtional for small to medium color dispalys Generate coce

Expected behavior files shoudld be able to be compiled

Actual file xx _menu.h is created with this include (shjould not be using brackets but " )

#include <../ThemeDarkModeTraditional.h>

additonally it seems other themes create this in cpp file and not in header

AtmosphEng commented 1 year ago

FYI: I've experienced something similar with tcmenu 3.1.0 for a while but didn't get around to reporting it until now. When I use the Designer Code Generation with the ThemeDarkModeTraditional on PlatformIO, I get the following linking error:

Linking .pio\build\lilygo-t-embed\firmware.elf c:/users/david/.platformio/packages/toolchain-xtensa-esp32s3/bin/../lib/gcc/xtensa-esp32s3-elf/8.4.0/../../../../xtensa-esp32s3-elf/bin/ld.exe: .pio/build/lilygo-t-embed/src/TcmSimpleTest_menu.cpp.o: in function installDarkModeTraditionalTheme(tcgfx::GraphicsDeviceRenderer&, tcgfx::MenuFontDef const&, tcgfx::MenuFontDef const&, bool)': D:\SBOX\WORK\aaaPROJ\aaaProjects\TcmSimpleTest/src/ThemeDarkModeTraditional.h:16: multiple definition ofinstallDarkModeTraditionalTheme(tcgfx::GraphicsDeviceRenderer&, tcgfx::MenuFontDef const&, tcgfx::MenuFontDef const&, bool)'; .pio/build/lilygo-t-embed/src/TcmSimpleTest_main.cpp.o:D:\SBOX\WORK\aaaPROJ\aaaProjects\TcmSimpleTest/src/ThemeDarkModeTraditional.h:16: first defined here collect2.exe: error: ld returned 1 exit status *** [.pio\build\lilygo-t-embed\firmware.elf] Error 1 ===================================================== [FAILED] Took 8.39 seconds ===

My workaround (found by experiment) has been to edit xyz_menu.h and cut-out the line containing:

include , and instead paste it at the top of xyz_menu.cpp. It then compiles OK. However, I need to do this cut and paste procedure after every Code Generation.

davetcc commented 1 year ago

Thanks for reporting this, I'll go through the theme plugins and check them all.