Register display and porting templates


Trying to do number 3 of the initialization process :

  1. Register the display and input devices drivers in LVGL. Learn more about Display and Input device registration

I realized that all described in diplay in indev htmls exist also as templates in lvgl/examples/porting/… (display_template or indev_template)

So i tried to use them and include these files in my main and call their init function. But i get some undecleared error which should not be there.

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


What LVGL version are you using?


What do you want to achieve?

Initial empty project on screen with v8.3

What have you tried so far?

I copied the templates and set if 1 first. I set the hor and ver size. Anylized what i was going to write in my main function and let the part of display registration and indev registration in these functions but system can not identify the registeration function that is declared in display.h.

My main is almost picked from porting program

Also i tried to place the porting templates in subfolder inside main but it had the same issue and i could not include also lvgl there.

If i put all code inside main.c build succeeds normally but it should not be a problem to have it in different file

Code to reproduce

#include "lvgl/examples/porting/lv_port_disp.h"
#include "lvgl/examples/porting/lv_port_indev.h"

SemaphoreHandle_t xGuiSemaphore;
lv_indev_t * touch_indev;
static void guiTask(void *pvParameter);
static void run_application(void);
static void lv_tick_task(void *arg);

void app_main(void)
    xTaskCreatePinnedToCore(guiTask, "gui", 4096*2, NULL, 0, NULL, 1);

static void guiTask(void *pvParameter) {

    (void) pvParameter;
    xGuiSemaphore = xSemaphoreCreateMutex();


    /* Initialize SPI or I2C bus used by the drivers */


    /* Register an input device when enabled on the menuconfig */

    const esp_timer_create_args_t periodic_timer_args = {
        .callback = &lv_tick_task,
        .name = "periodic_gui"
    esp_timer_handle_t periodic_timer;
    ESP_ERROR_CHECK(esp_timer_create(&periodic_timer_args, &periodic_timer));
    ESP_ERROR_CHECK(esp_timer_start_periodic(periodic_timer, portTICK_PERIOD_MS * 1000));
    while (1) {
        /* Delay 1 tick (assumes FreeRTOS tick is 10ms */

        /* Try to take the semaphore, call lvgl related function on success */
        if (pdTRUE == xSemaphoreTake(xGuiSemaphore, portMAX_DELAY)) {

static void run_application(void){
  lv_obj_t * scr = lv_disp_get_scr_act(NULL);
  lv_obj_t * label1 =  lv_label_create(scr);
  lv_label_set_text(label1, "Hello\nworld");
  lv_obj_align(label1, LV_ALIGN_CENTER, 0, 0);

static void lv_tick_task(void *arg) {

The error is

main/main.c:39: undefined reference to `lv_port_disp_init' // this line though is not lv_port_disp_init but lv_init() but this is wrong number identification
collect2: error: ld returned 1 exit status
ninja: build stopped: subcommand failed.