NCS 3.0.0: Linker errors when building LVGL project

Dear DevZone,

While porting our project from NCS 2.9.1 to NCS 3.0.0, I ran into linker errors when building LVGL. The linker reports that it cannot find functions defined in C:\ncs\v3.0.0\modules\lib\gui\lvgl\src\misc\lv_circle_buf.c. It appears that this file is not included in C:\ncs\v3.0.0\zephyr\modules\lvgl\CMakeLists.txt. After manually adding ${LVGL_DIR}/src/misc/lv_circle_buf.c to zephyr_library_sources() to that file, I was able to build the project without any linker errors.

Is this a bug or am I doing something wrong? 

Thanks,

Ladivin

  • Hello Ladivin,

    Did you try to run the sample on custom board? Can you please send me the project file to me?

  • Helo Kazi,

    many thanks for you quick response.

    Yes, we do have a custom board, but in the mean time I was able to reproduce this using nRF5340 DK. The simplest configuration to reproduce the issue is as follows (the project is attached as a zip file) :

    - Take hello world sample from Zephyr (from NCS 3.0.0) as a baseline

    - Add CONFIG_LVGL=y and CONFIG_DISPLAY=y to the prj.conf of this sample

    - Add app.overlay with a dummy display to the project. This overlay was taken from another zephyr sample

    - Add a call to any LVGL function that references functions from lv_circle_buf.c into your main -> in my case I just put lv_iter_destroy(NULL); 

    -Build this for nRF5340DK

    - Observe the linker error e.g. in function `lv_iter_destroy':
    C:/ncs/v3.0.0/modules/lib/gui/lvgl/src/misc/lv_iter.c:98: undefined reference to `lv_circle_buf_destroy'

    As stated before, this can be fixed by adding ${LVGL_DIR}/src/misc/lv_circle_buf.c to zephyr_library_sources() to C:\ncs\v3.0.0\zephyr\modules\lvgl\CMakeLists.txt

    I also tried this with NCS 3.0.but it made no difference. 

    Thanks!

    Ladivin

    hello_world_LVGL.zip

  • Hello Ladivin,

    I have tried to run your attached sample on nRf5340DK and I was able to run the sample. There were some warnings related to warning: implicit declaration of function 'lv_iter_destroy' [-Wimplicit-function-declaration] 

    Adding the following header files in the main.c file, solved the issue

    #include <lvgl.h>
    #include <zephyr/device.h>
    #include <zephyr/devicetree.h>
    #include <zephyr/drivers/display.h>

    This is the output I got

    I have not seen any other way to fix this issue. I have asked team. I will get back to you soon.

    Thanks.

    BR

    Kazi

  • I have the exact same issue, however only when putting LVGL into external XIP flash using:

    zephyr_code_relocate(LIBRARY modules__lvgl LOCATION EXTFLASH_TEXT NOCOPY)
    zephyr_code_relocate(LIBRARY modules__lvgl LOCATION RAM_DATA)
    Did you find any hints?
    Must be something related. It worked in 2.9.1 for me.
    Adding 
    zephyr_library_sources(${LVGL_ROOT_DIR}/src/misc/lv_circle_buf.c) in modules/lib/gui/lvgl/env_support/cmake/zephyr.cmake did not make any difference.
    arm-zephyr-eabi/bin/../lib/gcc/arm-zephyr-eabi/12.2.0/../../../../arm-zephyr-eabi/bin/ld.bfd: modules/lvgl/libmodules__lvgl.a(lv_iter.c.obj): in function `lv_iter_destroy':
    modules/lib/gui/lvgl/src/misc/lv_iter.c:98: undefined reference to `lv_circle_buf_destroy'
    arm-zephyr-eabi/bin/../lib/gcc/arm-zephyr-eabi/12.2.0/../../../../arm-zephyr-eabi/bin/ld.bfd: modules/lvgl/libmodules__lvgl.a(lv_iter.c.obj): in function `lv_iter_make_peekable':
    modules/lib/gui/lvgl/src/misc/lv_iter.c:112: undefined reference to `lv_circle_buf_create'
    arm-zephyr-eabi/bin/../lib/gcc/arm-zephyr-eabi/12.2.0/../../../../arm-zephyr-eabi/bin/ld.bfd: modules/lvgl/libmodules__lvgl.a(lv_iter.c.obj): in function `lv_iter_next':
    modules/lib/gui/lvgl/src/misc/lv_iter.c:122: undefined reference to `lv_circle_buf_is_empty'
    arm-zephyr-eabi/bin/../lib/gcc/arm-zephyr-eabi/12.2.0/../../../../arm-zephyr-eabi/bin/ld.bfd: modules/lib/gui/lvgl/src/misc/lv_iter.c:123: undefined reference to `lv_circle_buf_read'
    arm-zephyr-eabi/bin/../lib/gcc/arm-zephyr-eabi/12.2.0/../../../../arm-zephyr-eabi/bin/ld.bfd: modules/lib/gui/lvgl/src/misc/lv_iter.c:124: undefined reference to `lv_circle_buf_skip'
    arm-zephyr-eabi/bin/../lib/gcc/arm-zephyr-eabi/12.2.0/../../../../arm-zephyr-eabi/bin/ld.bfd: modules/lvgl/libmodules__lvgl.a(lv_iter.c.obj): in function `lv_iter_peek':
    modules/lib/gui/lvgl/src/misc/lv_iter.c:145: undefined reference to `lv_circle_buf_size'
    arm-zephyr-eabi/bin/../lib/gcc/arm-zephyr-eabi/12.2.0/../../../../arm-zephyr-eabi/bin/ld.bfd: modules/lib/gui/lvgl/src/misc/lv_iter.c:148: undefined reference to `lv_circle_buf_fill'
    arm-zephyr-eabi/bin/../lib/gcc/arm-zephyr-eabi/12.2.0/../../../../arm-zephyr-eabi/bin/ld.bfd: modules/lib/gui/lvgl/src/misc/lv_iter.c:152: undefined reference to `lv_circle_buf_peek_at'
    arm-zephyr-eabi/bin/../lib/gcc/arm-zephyr-eabi/12.2.0/../../../../arm-zephyr-eabi/bin/ld.bfd: modules/lvgl/libmodules__lvgl.a(lv_iter.c.obj): in function `lv_iter_peek_advance':
    modules/lib/gui/lvgl/src/misc/lv_iter.c:162: undefined reference to `lv_circle_buf_capacity'
    Edit:
    Found the issue, the file is missing in this file zephyr/modules/lvgl/CMakeLists.txt
    I was also adding the zephyr_library_sources to the wrong cmake file, did it in the one zephyr.cmake inside lvgl, which is not the one used.
Related