Running LittlevGL in C on IDE

Hi everyone,

Currently, I am working on Integrating LittlevGL into a project. The project is built on Keil C uVision with the help of STM32CubeMX. I intended to build and download the successfully built project into STM32L4R9I-DISC.
I follow the instruction from this link:

There are some initial parts of my work is on this link:

However, I am stuck at this error:
2019-12-24 2019-12-24.png

Could anyone help me to fix these errors?

I did some research on these errors and I found this link:

As @embeddedt answered, I haven’t compiled and linked LittlevGL yet, just built main.c . I am abit confused at this.

LittlevGL consists of numerous source files which also need to be compiled and linked with your project. Have you added the lvgl folder to your build system? Do you see lv_xxx.c being compiled in the build log? There isn’t a lot of information to work with here.

Hi @embeddedt,

Thank you for replying my post.

I did add the folder lvgl in my project, the same place as MDK-ARM, Inc, and Src. I am a bit confused about the instruction because they only said “Copy the lvgl folder into your project” without any specific location, so i put at that place:

I don’t think lv_xxx.c files are compiled. I also wonder about this. The only lvgl part appeared in compile log is this part and there are some warnings:

what kind of information should i need to provide to you?

It looks like you need to add the lv_xxx.c files to your build system. The exact steps to do that depend on your IDE. This might be of some use if you are using uVision.

Hi @embeddedt,

Thanks for giving me the link.

As i referred your link, I already fix those errors. Then, I met the error that “set_px is defined implicitly”. I tried to change set_px to put_px (from this link: but it did not work. I tried to see if there is any other error after that by commenting the put_px line. The next error is L6050U: the code size of this image (44226 bytes) exceeds the maximum allowed for this version of the linker.

So i changed to use STM32CubeIDE. But I met another error like this:

Do you, by any chance, know what the solution of this error?

I assume you were also the one who opened

There is no liblvgl.a , so you shouldn’t be adding LittlevGL to the library section of your IDE. You should just compile the source files as though they were part of your project.

Hi @embeddedt,

Yes, I am that one. Sorry for posting in the wrong place.

Now I am back to the KeilC because I don’t get used to the way STM32CubeIDE works.
Currently I am facing this error:
compiling main.c…
…/Src/main.c(96): warning: #223-D: function “put_px” declared implicitly
put_px(x, y, color_p); / Put a pixel to the display.*/
…/Src/main.c(102): error: #167: argument of type “lv_disp_t *” is incompatible with parameter of type “lv_disp_drv_t "
…/Src/main.c(153): warning: #513-D: a value of type "void (
)(lv_disp_t *, const lv_area_t *, lv_color_t )" cannot be assigned to an entity of type "void ()(struct _disp_drv_t *, const lv_area_t *, lv_color_t *)”
disp_drv.flush_cb = my_disp_flush; /Set your driver function/
…/Src/main.c: 2 warnings, 1 error
“LCD_LVGL\LCD_LVGL.axf” - 1 Error(s), 2 Warning(s).

Here is the Github repo I just created. Sorry because I posted everything at once so there is not much information about changes I made.
Could you please have a look at that repo?

Everything I did I followed the instruction from the lvgl repo. There are 2 extra changes i made:

  • I deleted “return 0” of function lv_color_to16 in lv_color.h because i met this error:
    …/Src/…/lvgl/src/lv_hal/…/lv_misc/lv_color.h(378): warning: #111-D: statement is unreachable
    return 0;
    I did as instructed from answers online.
  • I changed “lvgl/lvgl.h” to “…/lvgl/lvgl.h” in file lv_api_map.h because after i fixed the previous errors, it appeared an error at that place.

Thank you for uploading the GitHub repository; it makes it much easier to see the problem.

The first warning is caused by the fact that you do not have a put_px function defined anywhere in that file.

The error appears because my_disp_flush should take an initial parameter of lv_disp_drv_t *, not lv_disp_t *.

HI @embeddedt,

I should have done this earlier. Do you mind looking at the position of lv_conf.h and lvgl.h to see if they are placed correctly and also their inclusion in the file main.c and lv_api_map.h . I put them as the instruction from repo lvgl.

So that means I have to write the function put_px myself. So far, I did some searching but I could not find any material for me to define this function.

I assume that i should change the definition of * disp from lv_disp_t to lv_disp_drv_t. I did that and now i met some other dozens of errors like this:2019-12-29 2019-12-29.png

Now I feel confused because I clone all the modules and submodules as well as do exactly as instruction in lvgl repo. How could there be something wrong?

HI @embeddedt,

I think I found my mistake.

After looking at this reference:
I figured out why my project met so many errors.

I will base on the reference to do the project again.

The my_disp_flush function is just an example. put_px is a placeholder for the code to draw a pixel on the screen.

If you want to define put_px, the function signature can be deduced fairly easily by reading the my_disp_flush function: void put_px(int32_t x, int32_t y, lv_color_t color).

You would obviously have to implement it for your particular display.

the project has been solved

you must add the lvgl folder to the Source Location

otherwise the stm32cubeide will not find any file witch is in the lvgl folder。

then you should add others folder to the include path,like this:

this is my folder Explorer