[Simulator]Problem changing the background image of the demo in the simulator

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

Codeblock c/c++

What LVGL version are you using?

release v5.2-rc

What do you want to achieve?

change the background image of the demo in the simulator

What have you tried so far?

following the instructions on the official webpage of lvgl about image converter https, using the online converter to convert the background image into one c file and putting the c file under the directory of lv_examples\lv_apps\demo. Then changing the relative two lines of codes in the demo.c file as instructed on the webpage. However, the compiling progress failed when I was trying to rebuild the project.

Code to reproduce

Add a code snippet which can run in the simulator. It should contain only the relevant code that compiles without errors when separated from your main code base.

#if LV_DEMO_WALLPAPER
LV_IMG_DECLARE(img_red_flower)
#endif

/**********************
 *      MACROS
 **********************/

/**********************
 *   GLOBAL FUNCTIONS
 **********************/

/**
 * Create a demo application
 */
void demo_create(void)
{
    lv_coord_t hres = lv_disp_get_hor_res(NULL);
    lv_coord_t vres = lv_disp_get_ver_res(NULL);

#if LV_DEMO_WALLPAPER
    lv_obj_t * wp = lv_img_create(lv_disp_get_scr_act(NULL), NULL);
    lv_img_set_src(wp, &img_red_flower);
    lv_obj_set_width(wp, hres * 4);
    lv_obj_set_protect(wp, LV_PROTECT_POS);
#endif

The code snippet you provided uses features from 6.1. Is there a mistake here?

What error(s) did you get?

I am not sure whether the version is 6.1, because I just check from the website to find the latest version, which I think is the version that I downloaded.

The logs said that there is an undefined reference to the image I want to use. Is it correct that I put the image and the converted c file in the same directory of demo.c?

You only need the converted C file. Since you’re using CodeBlocks, you’ll also need to manually add the file to the project by right clicking the folder in CodeBlocks, selecting “Add files”, and choosing that C file.

Now I can successfully change the background image and rebuild the project.
Thank you.