Undefined reference to 'lv_example_x_x' on PlatformIO

Hello I have a problem during the compilation of the LVGL libray if I put it in the lib folder of my PlatformIO project. The Bug appens only when i enable the compilation of an example. Here is the issue on the LVGL github where i explain all the details.
Following my last comment where I tried to fix by forcing the compilation of the examples folder of LVGL, using build_src_filter in my ini, i get this error:

Compiling .pio\build\blackpill_f401cc\libae4\lvgl\core\lv_obj_scroll.c.o
In file included from .pio\libdeps\blackpill_f401cc\TFT_eSPI\TFT_eSPI.cpp:16:
.pio\libdeps\blackpill_f401cc\TFT_eSPI\TFT_eSPI.h:32:10: fatal error: SPI.h: No such file or directory   

*************************************************************
* Looking for SPI.h dependency? Check our library registry!
*
* CLI  > platformio lib search "header:SPI.h"
* Web  > https://registry.platformio.org/search?q=header:SPI.h
*
*************************************************************

   32 | #include <SPI.h>
      |          ^~~~~~~
compilation terminated.
*** [.pio\build\blackpill_f401cc\libf81\TFT_eSPI\TFT_eSPI.cpp.o] Error 1
====================================== [FAILED] Took 27.77 seconds ======================================

So i tried to fix it by adding the SPI library under lib_deps in my .ini file and I get this different error:

Indexing .pio\build\blackpill_f401cc\libFrameworkArduino.a
Linking .pio\build\blackpill_f401cc\firmware.elf
c:/users/franc/.platformio/packages/toolchain-gccarmnoneeabi/bin/../lib/gcc/arm-none-eabi/9.2.1/../../../../arm-none-eabi/bin/ld.exe: .pio/build/blackpill_f401cc/libFrameworkArduino.a(main.cpp.o): in function `main':
main.cpp:(.text.startup.main+0x6): undefined reference to `setup'
c:/users/franc/.platformio/packages/toolchain-gccarmnoneeabi/bin/../lib/gcc/arm-none-eabi/9.2.1/../../../../arm-none-eabi/bin/ld.exe: main.cpp:(.text.startup.main+0xa): undefined reference to `loop'
collect2.exe: error: ld returned 1 exit status
*** [.pio\build\blackpill_f401cc\firmware.elf] Error 1
====================================== [FAILED] Took 39.21 seconds =====================================

At this point I don’t know what may be causing this. Nor i found the issue that retained the examples folder of LVGL from compiling

It’s extremely bad to overwrite the main() function when working with framework = arduino (it’s overwriting the main() function as defined by the Arduino core) as well as working in a .c file (needs to be .cpp). I recommend you to delete that file and write main.cpp instead as

#include "lvgl.h"
#include "app_hal.h"
#include "demos/lv_demos.h"

void setup() {
   lv_init();
   hal_setup();
   lv_demo_widgets();
}

void loop() {
   hal_loop();
}


I am having the same problem with lvgl and PIO for esp32. The main() you referred is for running lvgl on Linux and not used for esp32. So, I don’t think it’s the problem here. What I found work is that if the “examples” folder is renamed to something else (e.g. “Xexamples”). Here is the lvgl library.json:

{
“name”: “lvgl”,
“version”: “8.3.9”,
“keywords”: “graphics, gui, embedded, tft, lvgl”,
“description”: “Graphics library to create embedded GUI with easy-to-use graphical elements, beautiful visual effects and low memory footprint. It offers anti-aliasing, opacity, and animations using only one frame buffer.”,
“repository”: {
“type”: “git”,
“url”: “GitHub - lvgl/lvgl: Embedded graphics library to create beautiful UIs for any MCU, MPU and display type. It's boosted by a professional yet affordable drag and drop UI editor, called SquareLine Studio.
},
“build”: {
“includeDir”: “.”
},
“license”: “MIT”,
“homepage”: “https://lvgl.io”,
“frameworks”: “",
“platforms”: "

}

As you can see there is no “srcFilter” so it’s not filtering out “examples”. However, it seems that there is a default filter somewhere for library build process that filters out “examples”. Do you have some idea what could be causing this? Thanks.