LVGL Demo: undefined reference to `SDL_Delay'

I am trying to run LVGL Demo (GitHub - lvgl/lv_platformio: PlatformIO project example for LVGL) on an ESP8266 and ili9341 display

I can run a custom code with Adafruit lib and I can run the LVGL on the simulator.

My platformio.ini is below

When I try to run the LVGL Demo on the board I get this error:

Linking .pio/build/env1/firmware.elf
/Users/eduardo/.platformio/packages/toolchain-xtensa/bin/../lib/gcc/xtensa-lx106-elf/10.3.0/../../../../xtensa-lx106-elf/bin/ld: .pio/build/env1/firmware.elf section `.rodata' will not fit in region `dram0_0_seg'
/Users/eduardo/.platformio/packages/toolchain-xtensa/bin/../lib/gcc/xtensa-lx106-elf/10.3.0/../../../../xtensa-lx106-elf/bin/ld: address 0x4000b4e8 of .pio/build/env1/firmware.elf section `.bss' is not within region `dram0_0_seg'
/Users/eduardo/.platformio/packages/toolchain-xtensa/bin/../lib/gcc/xtensa-lx106-elf/10.3.0/../../../../xtensa-lx106-elf/bin/ld: address 0x4000b4e8 of .pio/build/env1/firmware.elf section `.bss' is not within region `dram0_0_seg'
/Users/eduardo/.platformio/packages/toolchain-xtensa/bin/../lib/gcc/xtensa-lx106-elf/10.3.0/../../../../xtensa-lx106-elf/bin/ld: .pio/build/env1/lib04c/lv_drivers/sdl/sdl.c.o:(.text.tick_thread+0x0): undefined reference to `SDL_Delay'
/Users/eduardo/.platformio/packages/toolchain-xtensa/bin/../lib/gcc/xtensa-lx106-elf/10.3.0/../../../../xtensa-lx106-elf/bin/ld: .pio/build/env1/lib04c/lv_drivers/sdl/sdl.c.o: in function `tick_thread':
sdl.c:(.text.tick_thread+0x12): undefined reference to `SDL_Delay'
/Users/eduardo/.platformio/packages/toolchain-xtensa/bin/../lib/gcc/xtensa-lx106-elf/10.3.0/../../../../xtensa-lx106-elf/bin/ld: .pio/build/env1/lib04c/lv_drivers/sdl/sdl.c.o:(.text.window_update$constprop$0+0x4): undefined reference to `SDL_UpdateTexture'
/Users/eduardo/.platformio/packages/toolchain-xtensa/bin/../lib/gcc/xtensa-lx106-elf/10.3.0/../../../../xtensa-lx106-elf/bin/ld: .pio/build/env1/lib04c/lv_drivers/sdl/sdl.c.o:(.text.window_update$constprop$0+0x8): undefined reference to `SDL_RenderClear'
/Users/eduardo/.platformio/packages/toolchain-xtensa/bin/../lib/gcc/xtensa-lx106-elf/10.3.0/../../../../xtensa-lx106-elf/bin/ld: .pio/build/env1/lib04c/lv_drivers/sdl/sdl.c.o:(.text.window_update$constprop$0+0xc): undefined reference to `SDL_RenderCopy'
/Users/eduardo/.platformio/packages/toolchain-xtensa/bin/../lib/gcc/xtensa-lx106-elf/10.3.0/../../../../xtensa-lx106-elf/bin/ld: .pio/build/env1/lib04c/lv_drivers/sdl/sdl.c.o:(.text.window_update$constprop$0+0x10): undefined reference to `SDL_RenderPresent'
/Users/eduardo/.platformio/packages/toolchain-xtensa/bin/../lib/gcc/xtensa-lx106-elf/10.3.0/../../../../xtensa-lx106-elf/bin/ld: .pio/build/env1/lib04c/lv_drivers/sdl/sdl.c.o: in function `window_update$constprop$0':
sdl.c:(.text.window_update$constprop$0+0x28): undefined reference to `SDL_UpdateTexture'
/Users/eduardo/.platformio/packages/toolchain-xtensa/bin/../lib/gcc/xtensa-lx106-elf/10.3.0/../../../../xtensa-lx106-elf/bin/ld: sdl.c:(.text.window_update$constprop$0+0x30): undefined reference to `SDL_RenderClear'
/Users/eduardo/.platformio/packages/toolchain-xtensa/bin/../lib/gcc/xtensa-lx106-elf/10.3.0/../../../../xtensa-lx106-elf/bin/ld: sdl.c:(.text.window_update$constprop$0+0x3e): undefined reference to `SDL_RenderCopy'
/Users/eduardo/.platformio/packages/toolchain-xtensa/bin/../lib/gcc/xtensa-lx106-elf/10.3.0/../../../../xtensa-lx106-elf/bin/ld: .pio/build/env1/lib04c/lv_drivers/sdl/sdl.c.o:(.text.sdl_event_handler+0x30): undefined reference to `SDL_PollEvent'
/Users/eduardo/.platformio/packages/toolchain-xtensa/bin/../lib/gcc/xtensa-lx106-elf/10.3.0/../../../../xtensa-lx106-elf/bin/ld: .pio/build/env1/lib04c/lv_drivers/sdl/sdl.c.o:(.text.sdl_event_handler+0x34): undefined reference to `SDL_DestroyTexture'
/Users/eduardo/.platformio/packages/toolchain-xtensa/bin/../lib/gcc/xtensa-lx106-elf/10.3.0/../../../../xtensa-lx106-elf/bin/ld: .pio/build/env1/lib04c/lv_drivers/sdl/sdl.c.o:(.text.sdl_event_handler+0x38): undefined reference to `SDL_DestroyRenderer'
/Users/eduardo/.platformio/packages/toolchain-xtensa/bin/../lib/gcc/xtensa-lx106-elf/10.3.0/../../../../xtensa-lx106-elf/bin/ld: .pio/build/env1/lib04c/lv_drivers/sdl/sdl.c.o:(.text.sdl_event_handler+0x3c): undefined reference to `SDL_DestroyWindow'
/Users/eduardo/.platformio/packages/toolchain-xtensa/bin/../lib/gcc/xtensa-lx106-elf/10.3.0/../../../../xtensa-lx106-elf/bin/ld: .pio/build/env1/lib04c/lv_drivers/sdl/sdl.c.o:(.text.sdl_event_handler+0x40): undefined reference to `SDL_Quit'
/Users/eduardo/.platformio/packages/toolchain-xtensa/bin/../lib/gcc/xtensa-lx106-elf/10.3.0/../../../../xtensa-lx106-elf/bin/ld: .pio/build/env1/lib04c/lv_drivers/sdl/sdl.c.o: in function `sdl_event_handler':
sdl.c:(.text.sdl_event_handler+0x288): undefined reference to `SDL_PollEvent'
/Users/eduardo/.platformio/packages/toolchain-xtensa/bin/../lib/gcc/xtensa-lx106-elf/10.3.0/../../../../xtensa-lx106-elf/bin/ld: sdl.c:(.text.sdl_event_handler+0x2a3): undefined reference to `SDL_DestroyTexture'
/Users/eduardo/.platformio/packages/toolchain-xtensa/bin/../lib/gcc/xtensa-lx106-elf/10.3.0/../../../../xtensa-lx106-elf/bin/ld: sdl.c:(.text.sdl_event_handler+0x2ab): undefined reference to `SDL_DestroyRenderer'
/Users/eduardo/.platformio/packages/toolchain-xtensa/bin/../lib/gcc/xtensa-lx106-elf/10.3.0/../../../../xtensa-lx106-elf/bin/ld: sdl.c:(.text.sdl_event_handler+0x2b3): undefined reference to `SDL_DestroyWindow'
/Users/eduardo/.platformio/packages/toolchain-xtensa/bin/../lib/gcc/xtensa-lx106-elf/10.3.0/../../../../xtensa-lx106-elf/bin/ld: sdl.c:(.text.sdl_event_handler+0x2b9): undefined reference to `SDL_Quit'
/Users/eduardo/.platformio/packages/toolchain-xtensa/bin/../lib/gcc/xtensa-lx106-elf/10.3.0/../../../../xtensa-lx106-elf/bin/ld: .pio/build/env1/lib04c/lv_drivers/sdl/sdl.c.o:(.text.sdl_init+0x1c): undefined reference to `SDL_Init'
/Users/eduardo/.platformio/packages/toolchain-xtensa/bin/../lib/gcc/xtensa-lx106-elf/10.3.0/../../../../xtensa-lx106-elf/bin/ld: .pio/build/env1/lib04c/lv_drivers/sdl/sdl.c.o:(.text.sdl_init+0x20): undefined reference to `SDL_SetEventFilter'
/Users/eduardo/.platformio/packages/toolchain-xtensa/bin/../lib/gcc/xtensa-lx106-elf/10.3.0/../../../../xtensa-lx106-elf/bin/ld: .pio/build/env1/lib04c/lv_drivers/sdl/sdl.c.o:(.text.sdl_init+0x24): undefined reference to `SDL_CreateWindow'
/Users/eduardo/.platformio/packages/toolchain-xtensa/bin/../lib/gcc/xtensa-lx106-elf/10.3.0/../../../../xtensa-lx106-elf/bin/ld: .pio/build/env1/lib04c/lv_drivers/sdl/sdl.c.o:(.text.sdl_init+0x28): undefined reference to `SDL_CreateRenderer'
/Users/eduardo/.platformio/packages/toolchain-xtensa/bin/../lib/gcc/xtensa-lx106-elf/10.3.0/../../../../xtensa-lx106-elf/bin/ld: .pio/build/env1/lib04c/lv_drivers/sdl/sdl.c.o:(.text.sdl_init+0x2c): undefined reference to `SDL_CreateTexture'
/Users/eduardo/.platformio/packages/toolchain-xtensa/bin/../lib/gcc/xtensa-lx106-elf/10.3.0/../../../../xtensa-lx106-elf/bin/ld: .pio/build/env1/lib04c/lv_drivers/sdl/sdl.c.o:(.text.sdl_init+0x30): undefined reference to `SDL_SetTextureBlendMode'
/Users/eduardo/.platformio/packages/toolchain-xtensa/bin/../lib/gcc/xtensa-lx106-elf/10.3.0/../../../../xtensa-lx106-elf/bin/ld: .pio/build/env1/lib04c/lv_drivers/sdl/sdl.c.o:(.text.sdl_init+0x34): undefined reference to `SDL_StartTextInput'
/Users/eduardo/.platformio/packages/toolchain-xtensa/bin/../lib/gcc/xtensa-lx106-elf/10.3.0/../../../../xtensa-lx106-elf/bin/ld: .pio/build/env1/lib04c/lv_drivers/sdl/sdl.c.o:(.text.sdl_init+0x38): undefined reference to `SDL_CreateThread'
/Users/eduardo/.platformio/packages/toolchain-xtensa/bin/../lib/gcc/xtensa-lx106-elf/10.3.0/../../../../xtensa-lx106-elf/bin/ld: .pio/build/env1/lib04c/lv_drivers/sdl/sdl.c.o:(.text.sdl_init+0x4b): undefined reference to `SDL_Init'
/Users/eduardo/.platformio/packages/toolchain-xtensa/bin/../lib/gcc/xtensa-lx106-elf/10.3.0/../../../../xtensa-lx106-elf/bin/ld: .pio/build/env1/lib04c/lv_drivers/sdl/sdl.c.o: in function `sdl_init':
sdl.c:(.text.sdl_init+0x57): undefined reference to `SDL_SetEventFilter'
/Users/eduardo/.platformio/packages/toolchain-xtensa/bin/../lib/gcc/xtensa-lx106-elf/10.3.0/../../../../xtensa-lx106-elf/bin/ld: sdl.c:(.text.sdl_init+0x6f): undefined reference to `SDL_CreateWindow'
/Users/eduardo/.platformio/packages/toolchain-xtensa/bin/../lib/gcc/xtensa-lx106-elf/10.3.0/../../../../xtensa-lx106-elf/bin/ld: sdl.c:(.text.sdl_init+0x7f): undefined reference to `SDL_CreateRenderer'
/Users/eduardo/.platformio/packages/toolchain-xtensa/bin/../lib/gcc/xtensa-lx106-elf/10.3.0/../../../../xtensa-lx106-elf/bin/ld: sdl.c:(.text.sdl_init+0x93): undefined reference to `SDL_CreateTexture'
/Users/eduardo/.platformio/packages/toolchain-xtensa/bin/../lib/gcc/xtensa-lx106-elf/10.3.0/../../../../xtensa-lx106-elf/bin/ld: sdl.c:(.text.sdl_init+0xa4): undefined reference to `SDL_SetTextureBlendMode'
/Users/eduardo/.platformio/packages/toolchain-xtensa/bin/../lib/gcc/xtensa-lx106-elf/10.3.0/../../../../xtensa-lx106-elf/bin/ld: sdl.c:(.text.sdl_init+0xc6): undefined reference to `SDL_StartTextInput'
/Users/eduardo/.platformio/packages/toolchain-xtensa/bin/../lib/gcc/xtensa-lx106-elf/10.3.0/../../../../xtensa-lx106-elf/bin/ld: sdl.c:(.text.sdl_init+0xd4): undefined reference to `SDL_CreateThread'
/Users/eduardo/.platformio/packages/toolchain-xtensa/bin/../lib/gcc/xtensa-lx106-elf/10.3.0/../../../../xtensa-lx106-elf/bin/ld: .pio/build/env1/hal/sdl2/app_hal.c.o: in function `tick_thread':
app_hal.c:(.text.tick_thread+0xe): undefined reference to `SDL_Delay'
/Users/eduardo/.platformio/packages/toolchain-xtensa/bin/../lib/gcc/xtensa-lx106-elf/10.3.0/../../../../xtensa-lx106-elf/bin/ld: .pio/build/env1/hal/sdl2/app_hal.c.o:(.text.hal_loop+0x7): undefined reference to `SDL_Delay'
collect2: error: ld returned 1 exit status
*** [.pio/build/env1/firmware.elf] Error 1

The Platformio.ini looks like

; PlatformIO Project Configuration File
;
;   Build options: build flags, source filter
;   Upload options: custom upload port, speed and extra flags
;   Library options: dependencies, extra library storages
;   Advanced options: extra scripting
;
; Please visit documentation for the other options and examples
; https://docs.platformio.org/page/projectconf.html

[platformio]
default_envs = env1

[env]
build_flags = 
	-D LV_CONF_SKIP
	-D LV_CONF_INCLUDE_SIMPLE
	-D LV_USE_DEMO_WIDGETS=1
lib_deps = lvgl=https://github.com/lvgl/lvgl/archive/refs/tags/v8.2.0.zip
lib_archive = no

[env:emulator_64bits]
platform = native@^1.1.3
extra_scripts = support/sdl2_build_extra.py
build_flags = 
	${env.build_flags}
	-D LV_LOG_PRINTF=1
	!python -c "import os; print(' '.join(['-I {}'.format(i[0].replace('\x5C','/')) for i in os.walk('hal/sdl2')]))"
	-lSDL2
	-D LV_LVGL_H_INCLUDE_SIMPLE
	-D LV_DRV_NO_CONF
	-D USE_SDL
	-D SDL_HOR_RES=480
	-D SDL_VER_RES=320
	-D SDL_ZOOM=1
	-D SDL_INCLUDE_PATH="\"SDL2/SDL.h\""
	-D LV_MEM_CUSTOM=1
	-D LV_MEM_SIZE="(128U * 1024U)"

  -I /opt/homebrew/Cellar/sdl2/2.26.3/include
  -L /opt/homebrew/Cellar/sdl2/2.26.3/lib

lib_deps = 
	${env.lib_deps}
	lv_drivers=https://github.com/lvgl/lv_drivers/archive/refs/tags/v8.2.0.zip
build_src_filter = 
	+<*>
	+<../hal/sdl2>
	+<../.pio/libdeps/emulator_64bits/lvgl/demos>

[env:emulator_32bits]
extends = env:emulator_64bits
build_flags = 
	${env:emulator_64bits.build_flags}
	-m32
build_src_filter = 
	+<*>
	+<../hal/sdl2>
	+<../.pio/libdeps/emulator_32bits/lvgl/demos>

[env:stm32f429_disco]
platform = ststm32@^8.0.0
board = disco_f429zi
framework = stm32cube
build_flags = 
	${env.build_flags}
	-D LV_LOG_LEVEL=LV_LOG_LEVEL_NONE
	-D HSE_VALUE=8000000
	!python -c "import os; print(' '.join(['-I {}'.format(i[0].replace('\x5C','/')) for i in os.walk('hal/stm32f429_disco')]))"
lib_deps = 
	${env.lib_deps}
	BSP-ili9341
	BSP-stmpe811
build_src_filter = 
	+<*>
	+<../hal/stm32f429_disco>
	+<../.pio/libdeps/stm32f429_disco/lvgl/demos>

[env:env1]
platform = espressif8266
board = nodemcuv2
framework = arduino
extra_scripts = support/sdl2_build_extra.py
build_flags = 
	${env.build_flags}
	-D LV_LOG_PRINTF=1
	!python -c "import os; print(' '.join(['-I {}'.format(i[0].replace('\x5C','/')) for i in os.walk('hal/sdl2')]))"
	-lSDL2
	-D LV_LVGL_H_INCLUDE_SIMPLE
	-D LV_DRV_NO_CONF
	-D USE_SDL
	-D SDL_HOR_RES=480
	-D SDL_VER_RES=320
	-D SDL_ZOOM=1
	-D SDL_INCLUDE_PATH="\"SDL2/SDL.h\""
	-D LV_MEM_CUSTOM=1
	-D LV_MEM_SIZE="(128U * 1024U)"

  -I /opt/homebrew/Cellar/sdl2/2.26.3/include
  -L /opt/homebrew/Cellar/sdl2/2.26.3/lib

lib_deps = 
	${env.lib_deps}
	lv_drivers=https://github.com/lvgl/lv_drivers/archive/refs/tags/v8.2.0.zip
	SPI
build_src_filter = 
	+<*>
	+<../hal/sdl2>
	+<../.pio/libdeps/emulator_64bits/lvgl/demos>

Listing the folder “/opt/homebrew/Cellar/sdl2/2.26.3/include/SDL2” I don’t see the “SDL_Delay”

This looks really wrong. SDL is a library for desktop, not to be used on ESP8266. Adding include and library paths for SDL meant for your desktop will lead to mayhem.

Get rid of all SDL references in the EPS8266 config, especially USE_SDL, SDL_*, the SDL -I and -L paths and the extra_script.

ok. Tks

I managed to progress, and I can compile.

I get this error now.

/Users/eduardo/.platformio/packages/toolchain-xtensa/bin/../lib/gcc/xtensa-lx106-elf/10.3.0/../../../../xtensa-lx106-elf/bin/ld: address 0x3fffe470 of .pio/build/env1/firmware.elf section `.bss' is not within region `dram0_0_seg'
/Users/eduardo/.platformio/packages/toolchain-xtensa/bin/../lib/gcc/xtensa-lx106-elf/10.3.0/../../../../xtensa-lx106-elf/bin/ld: address 0x3fffe470 of .pio/build/env1/firmware.elf section `.bss' is not within region `dram0_0_seg'
/Users/eduardo/.platformio/packages/toolchain-xtensa/bin/../lib/gcc/xtensa-lx106-elf/10.3.0/../../../../xtensa-lx106-elf/bin/ld: .pio/build/env1/src/main.c.o:(.text.setup+0x0): undefined reference to `lv_demo_widgets'
collect2: error: ld returned 1 exit status
*** [.pio/build/env1/firmware.elf] Error 1

the current platformio.ini looks like:

[env]
build_flags = 
	-D LV_CONF_SKIP
	-D LV_CONF_INCLUDE_SIMPLE
	-D LV_USE_DEMO_WIDGETS=1
  -D LV_COLOR_16_SWAP=1
lib_deps = lvgl=https://github.com/lvgl/lvgl/archive/refs/tags/v8.2.0.zip
lib_archive = no

[env:env1]
platform = espressif8266
board = nodemcuv2
framework = arduino

“Something” is using a ton of RAM and it fails the build. Probably some memory size for a buffer is set way too high for the poor ESP8266’s RAM. Try to check your configuration files you use regarding resolutions and buffer sizes.

Otherwise, the ‘hard’ way is to go hack the linker scripts to artificially increase the RAM size and then analyze the .elf / .map file to see what’s taking up the memory, akin to [ESP32] ld: region `dram0_0_seg' overflowed by 156768 bytes.