Showing Undefined reference for LVGL functions

Description

Hi I want to use LVGL on Linux, I want to use it through framebuffer option and want to run on it. My LVGL version is 9.1

What MCU/Processor/Board and compiler are you using?

Ultimately I want to run LVGL on raspberry pi board, but before that I want to run on linux desktop through framebuffer. I am using gcc compiler and makefile.

What do you want to achieve?

I want to develop the GUI based on LVGL and also my raspberry pi will drive the hardware such as ADC and motors at backend.

What have you tried so far?

I have gone through all the LVGL documentation given and done the necessary steps which are showed. I have wrote one samll program and I have just called lv_init() function in main. When I compile it it shows me undefined reference to lv_init();

Code to reproduce

The code block(s) should be between ```c and ``` tags:

/*You code here*/
#include <unistd.h>
#include "lvgl/lvgl.h"

int main(void)
{
    /*LVGL init*/
	lv_init();
// Linux frame buffer device init
//    lv_display_t *display = lv_linux_fbdev_create();
//    lv_linux_fbdev_set_file(display, "/dev/fb0");
//    lv_example_get_started_1();

    // Handle LitlevGL tasks (tickless mode)
/*    while(1) {
        lv_tick_inc(5);
        lv_timer_handler();
        usleep(5000);
    }
*/
    return 0;
}
/*You code ends here*/

Following is the output when I compiles the code

gcc   main.c -o hello_world  -Wall
/usr/bin/ld: /tmp/ccr8OWhh.o: in function `main':
main.c:(.text+0x9): undefined reference to `lv_init'
collect2: error: ld returned 1 exit status
make: *** [Makefile:10: all] Error 1
[date=2024-04-15 time=18:02:00 timezone="Asia/Calcutta"]
If I remove the lv_init(); function from main then program gets compiled.

Following is the makefile.

#make file - this is a comment section
CC=gcc  #compiler

TARGET=hello_world #target file name

WARNING_FLAG=Wall
include lvgl/lvgl.mk

all:
	$(CC) main.c -o $(TARGET) -$(WARNING_FLAG)
  
clean:
	rm $(TARGET)

Following is the screen shot of directory structure, inside my project folder. Is this correct ?

![Screenshot from 2024-04-15 18-00-43|690x406](upload://Ac8QU0u6pV9rn8TBj05tA0ykJFE.png)

Please let me know where I am wrong.
Thanks in advance.

Your best starting point for linux frame buffer.

Hi @deonm thanks for this linux frame buffer tutorial, I tried this at my end, but nothing appears on the display. I followed the steps given, but I am getting this following message on screens.

sudo ./main
[Warn] (0.000, +0) lv_init: Memory integrity checks are enabled via LV_USE_ASSERT_MEM_INTEGRITY which makes LVGL much slower lv_init.c:233
[Warn] (0.000, +0) lv_init: Object sanity checks are enabled via LV_USE_ASSERT_OBJ which makes LVGL much slower lv_init.c:237
[Warn] (0.000, +0) lv_init: Style sanity checks are enabled that uses more RAM lv_init.c:241

Do I need a CMake instead of makefile in my project ?

Thanks in advance

If you have cmake installed and then you just need to follow the readme in the repo.

You should not have the desktop running. From the link int he readme,
Embedded GUI Using Linux Frame Buffer Device with LVGL | LVGL’s Blog.

Depending on which OS you are running and which Raspberry Pi you are using you may need to disable the vc4-kms-v3d driver in
/boot/config.txt or /boot/firmware/config.txt if you are running bookworm.
If you need to disable it, then it should look like this,

# Enable DRM VC4 V3D driver
#dtoverlay=vc4-kms-v3d