Compile errors undefined reference to `ui_Screen1_screen_init

Hi, I am trying to load my first SLS UI to a LilygoT-Watch 2021 with Arduino IDE. Initially I got a lot of [unknown type name ‘lv_obj_t’] compilation errors and it looks like I solved them removing empty spaces in my SLS project name, after reading this post Arduino compiling error - #16 by ii_mud

Now I only getting three errors, as follows:

c:/users/angel/appdata/local/arduino15/packages/esp32/tools/xtensa-esp32-elf-gcc/esp-2021r2-patch5-8.4.0/bin/…/lib/gcc/xtensa-esp32-elf/8.4.0/…/…/…/…/xtensa-esp32-elf/bin/ld.exe: C:\Users\angel\AppData\Local\Temp\arduino\sketches\BC501AACDEF7F1DD816042893F9DB3D3\sketch\objs.a(ui.c.o):(.literal.ui_init+0xc): undefined reference to ui_Screen1_screen_init' c:/users/angel/appdata/local/arduino15/packages/esp32/tools/xtensa-esp32-elf-gcc/esp-2021r2-patch5-8.4.0/bin/../lib/gcc/xtensa-esp32-elf/8.4.0/../../../../xtensa-esp32-elf/bin/ld.exe: C:\Users\angel\AppData\Local\Temp\arduino\sketches\BC501AACDEF7F1DD816042893F9DB3D3\sketch\objs.a(ui.c.o): in function ui_init’:
C:\Users\angel\Documents\Arduino\Prova_Angelo_UI_9lug/ui.c:94: undefined reference to `ui_Screen1_screen_init’
collect2.exe: error: ld returned 1 exit status

exit status 1

Compilation error: exit status 1

I tried to track them down but got completely confused when saw that two of them seem to point to files in the esp32/tools. The third one points to my ui.c code and I verified that ui_screen1_init actually appears in the code.

Any help is much appreciated!
Angelo

Same problem here. When SquareLine exports the UI files, ui.h declares ui_Screen1_screen_init but ui.c does not define it. So when compiling in the Arduino IDE, the compiler throws undefined reference to ui_Screen1_screen_init’`.

This happens for all the projects I’ve tried to export. For example, this is the complete content of ui.c generated for a project with one blank screen named ‘Screen1’:

// This file was generated by SquareLine Studio
// SquareLine Studio version: SquareLine Studio 1.3.0
// LVGL version: 8.3.6
// Project name: Test

#include "ui.h"
#include "ui_helpers.h"

///////////////////// VARIABLES ////////////////////

// SCREEN: ui_Screen1
void ui_Screen1_screen_init(void);
lv_obj_t * ui_Screen1;
lv_obj_t * ui____initial_actions0;

///////////////////// TEST LVGL SETTINGS ////////////////////
#if LV_COLOR_DEPTH != 16
    #error "LV_COLOR_DEPTH should be 16bit to match SquareLine Studio's settings"
#endif
#if LV_COLOR_16_SWAP !=0
    #error "LV_COLOR_16_SWAP should be 0 to match SquareLine Studio's settings"
#endif

///////////////////// ANIMATIONS ////////////////////

///////////////////// FUNCTIONS ////////////////////

///////////////////// SCREENS ////////////////////

void ui_init(void)
{
    lv_disp_t * dispp = lv_disp_get_default();
    lv_theme_t * theme = lv_theme_default_init(dispp, lv_palette_main(LV_PALETTE_BLUE), lv_palette_main(LV_PALETTE_RED),
                                               false, LV_FONT_DEFAULT);
    lv_disp_set_theme(dispp, theme);
    ui_Screen1_screen_init();
    ui____initial_actions0 = lv_obj_create(NULL);
    lv_disp_load_scr(ui_Screen1);
}

1 Like

Figured it out. ui_Screen1_screen_init is defined in screens/Screen1.c.

I had tried to flatten the project folders so that I didn’t need to change the Arduino IDE sketchbook location to be this specific project’s folder and had not moved this file.

1 Like

Hi,
please take a look at this post: https://github.com/SquareLineStudio/board_arduino_tft_espi/tree/v1.1.0/__ui_project_name__/libraries/ui

1 Like

@kisvegabor thanks for your answer.
Today I can only access from my phone and maybe I am missing something that I would notice from my pc. I followed your link to a GitHub repo, but I couldn’t find any instructions explaining what that code is for, or how it could solve my problem.
Could you please clarify?
Angelo

@benlye if I got it correctly, I will check later (probably tomorrow as today I won’t be home) that my sketch folder contains a code file defining `ui_Screen1_screen’
I’ll let you know. Thanks!
Angelo

From SLS v1.3.0 we export the code in a directories. Unfortunately, Arduino doesn’t like folders next to the ino files, so we need to use the exported code as an Arduino library (where directories are supported). On the link that I’v send you can find a template library for the UI code. You can create the same directory structure in your library folder and export the code into the src folder.

We definitely need to figure out something simpler for this…

1 Like

@kisvegabor apologies but I’m probably too thick to understand this… I am having a hard time understanding the directory structure I’m supposed to create. I tried doing this


changing “board” and “project name” to my actual board and project name. But it doesn’t compile.
So I looked more at the folders on github and found this readme:

Is this what I am supposed to do?
Thanks for your patience.

It just came to my mind that we can create a special board in SLS which will export an Arduino library for the UI files. So it will do basically what you need to do manually here.

Until that, I attach a zip file. You need to copy it into Arduino’s library folder and export the UI files into the src folder. Let me know how it works.

ui.zip (1019 Bytes)

1 Like

That sounds good.

It might also make it easier to integrate the SLS output with other Arduino display libraries (rather than TFT_eSPI).

I’m lookin at Arduino_GFX and LovyanGFX for a couple of devices which aren’t supported by TFT_eSPI.

@kisvegabor thanks very much for your help! I just followed your instructions and it looks like I was able to compile.
Initially I had gotten some errors regarding some montserrat font (20 and 30) not implemented, so I switched them to 1 in the conf.h file and it looks like that fixed the issue.
Unfortunately I don’t have the board with me at the moment, so I won’t be able to test upload the code. I should do it tomorrow or Monday at the latest and then I’ll let you know.
Thanks again!
Angelo

1 Like

Great, thank you for the update!

In the meantime I started to work on the mentioned SLS Arduino library “board”.

@kisvegabor why not have an option in SLS to export a completely flat file structure? I just take all the exported .c and .h files, fix the includes (remove ../), and drop all the files into my Arduino IDE project folder.

I don’t care that there’s a a lot of files, and it save me doing any messing with the library folders.

1 Like

I was thinking about it and it seems like good idea. What we need is only a checkbox in the project settings.

I’ve discussed it with the others guys at SLS, and we will add it in the next release.

1 Like

@kisvegabor, I was finally able to upload on the board. Everything works, except my GUI does not appear on the display, I just get the backlight steady on.
I am currently looking for the solution, I must have missed something somewhere.

1 Like

I’ve been having the same error. And like you the workaround @kisvegabor suggested seems to at least allow compiling to finish. But I’m getting the same “backlight only” dark screen instead of the UI. In my case the UI is simply a single function-less button just as a test. Very frustrating.

I’m using a Makerfabs 4.3" display. Details are sketchy, but it seems to use an “HX8664/HX8264” LCD driver IC. If that has any bearing on why this isn’t working.

Hi, are you sure the display is working without LVGL and SLS? That is can you draw anything on it without calling lv_init and ui_init?

Not to hijack the thread (should I start a new one?) but in my case I can otherwise upload files and all works fine. Can place shapes, text, PNGs, etc. But so far Squareline only makes a dark blank screen. I’ve checked the background is set to white, fully opaque, etc.

@Drone601 I personally have no problem with using this topic to discuss your issue, which seems similar to mine. I have a very limited knowledge though.
I am still digging to find out some more about my issue. For example I noticed that after getting the black screen (backlight only) with the SLS UI code, I have been getting the same result with another LVGL code (the HELLOLVGL example code at this link: https://www.instructables.com/Design-a-Fancy-GUI-for-Your-Project/) that previously had worked fine for me. I am wondering if somewhere I messed up something which is impacting both codes…

1 Like

@kisvegabor today I managed to show the UI on the display! As I thought I had probably made some mistakes in copying the gfx and display declarations for my board.
It looks like everything is working for now. Now I have to implement some new functions, will write if I encounter other issues I can’t solve… thanks all for your help!

1 Like