LVGL and lv_demo_widgets undefined reference


I try to start a demo from LVGL but I get a compiler error, see below.
I included LVGL as following (installed over library manager).
Even in lv_conf.h the demos are activated/defined, when I check the demo C-files, it looks it does not recognize that it is defined, still marked out.

What can I try?

#include <lvgl.h>
#include "demos/lv_demos.h"
platform = raspberrypi
board = pico
framework = arduino
lib_deps = lvgl/lvgl@^8.3.4
upload_protocol = picotool
.platformio/packages/toolchain-gccarmnoneeabi/bin/../lib/gcc/arm-none-eabi/9.2.1/../../../../arm-none-eabi/bin/ld.exe: .pio\build\pico\src\main.cpp.o: in function `setup':
main.cpp:(.text.setup+0x9e): undefined reference to `lv_demo_widgets'
collect2.exe: error: ld returned 1 exit status
*** [.pio\build\pico\firmware.elf] Error 1

Did you copy the demos/widgets folder to the src of the project? lv_demo_widgets() is defined inside lv_demo_widgets.c.


build_flags = -DLV_USE_DEMO_WIDGETS

I solved it by copying the whole LVGL library to the src-folder, but maybe your above suggestion would also have work.

1 Like

Thank you so much for posting this, I had already spent many hours trying to troubleshoot a similar issue. This did the trick for me; my assumption is that it was not correctly reading ld_config which was causing strange issues.