**New User** Help with getting an executable from CMake...can't find ui.h functions

What do you want to achieve?

I want to create an executable from the generated UI code using the generated cmake file

What have you tried so far?

I successfully compiled and created an executable for the LVGL example project using the SDL2 simulator, so I know it works. I am trying to recreate this but instead of the LVGL example, have it run my SquareLine generated UI code. I have:

1: Added “add_subdirectory(ui)” in the highest level CMakeLists.txt file as stated in SquareLine documentation
2: when running make, compiles all the way, but gives the error shown below (Undefined symbols, _ui_init, referenced from: _main in main.c.o, when I try to use “ui_init()” in main.c
3: If I remove ui_init() from main.c, the project compiles and creates the executable, so I am assuming something is wrong with the cmake causing it to not find the functions in the ui.h file

Thanks in advance, new user

Screenshot or video

Terminal showing successful compiling, but final error where it can’t find ui_init in my main.c

Top level CMakeLists.txt file showing the “add_subdirectory(ui)”, as said to call by SquareLine documentation

Main.c showing the lv_init() and ui_init() calls (will implement the SDL2 later)

Folder structure, all SquareLine generated ui files are in the “ui” folder


  • **SquareLine Studio version: latest
  • **Operating system: macOS
  • **Target hardware: MacOS (then Raspberry PI)

According to the error message the linker needs to be told the name of ui.c source-file which contained the ui_init() function. You may have more luck by adding it (and the other .c files) to the $SOURCES variable or directly to the list between the brackets in add_executable(main.c ${SOURCES} …)

Tip: To create a variable recursively from all .c filenames under ‘ui’ folder, you can use
and then add the resulting ${UI_Sources} variable between the brackets like:
add_executable(main.c ${SOURCES} ${UI_Sources})