Cmake Configuration for Qt Cross Compilation at Raspberry Zero
-
I need to cross compile lgvl Demo sample ( Beautiful font package based on C++ )into my Raspberry, SO i selected the Qt Creator which i have successfully cross compiled my others project in QT And C++, So i run it via my Linux MINT LMDE via Qt with this Cmake Settings;
cmake_minimum_required(VERSION 2.8) project(lvgl-sim-copy) file(GLOB_RECURSE LVGL_SRC "lvgl/*.c" ) include_directories(${CMAKE_SOURCE_DIR}) include_directories(lgvl) add_library(lvgl ${LVGL_SRC}) file(GLOB_RECURSE LVGL_DVR_SRC "lv_drivers/*.c" ) add_library(lvgl_drv ${LVGL_DVR_SRC}) file(GLOB_RECURSE DEMO_SRC "lv_examples/lv_apps/demo/*.[ch]") #file(GLOB CONF_HEADERS "*.h") #file(GLOB DEMO_SRC "*.h") file(GLOB_RECURSE DEMO_SRC2 "lv_examples/lv_apps/benchmark/*.[ch]") file(GLOB_RECURSE DEMO_SRC4 "lv_examples/lv_tests/lv_test_group/*.[ch]") file(GLOB_RECURSE DEMO_SRC3 "lv_examples/lv_tests/lv_test_theme/*.[ch]") file(GLOB_RECURSE DEMO_SRC5 "lv_examples/lv_tests/lv_test_objx/lv_test_imgbtn/*.[ch]") #add_library(lvgl_con_inc ${LV_CONF_INCLUDE_SIMPLE}) include_directories(${LV_CONF_INCLUDE_SIMPLE}) #add_executable(demo "main.c" ${CONF_HEADERS} ${DEMO_SRC}) add_executable(demo ${DEMO_SRC5} ${DEMO_SRC3} ${DEMO_SRC4} ${DEMO_SRC2} ${DEMO_SRC} "main.c" "lv_conf.h" "lv_ex_conf.h" "lv_drv_conf.h" "mouse_cursor_icon.c") find_package(SDL2) include_directories(${SDL2_INCLUDES}) target_link_libraries(demo lvgl lvgl_drv ${SDL2_LIBRARIES})
my main. file is:
/** * @file main * */ /********************* * INCLUDES *********************/ #define _DEFAULT_SOURCE /* needed for usleep() */ #include <stdlib.h> #include <unistd.h> #define SDL_MAIN_HANDLED /*To fix SDL's "undefined reference to WinMain" issue*/ #include <SDL2/SDL.h> #include "lvgl/lvgl.h" #include "lv_drivers/display/monitor.h" #include "lv_drivers/display/fbdev.h" #include "lv_drivers/indev/mouse.h" #include "lv_drivers/indev/mousewheel.h" #include "lv_drivers/indev/keyboard.h" #include "lv_examples/lv_apps/demo/demo.h" #include "lv_examples/lv_apps/benchmark/benchmark.h" #include "lv_examples/lv_tests/lv_test.h" /********************* * DEFINES *********************/ /*On OSX SDL needs different handling*/ #if defined(__APPLE__) && defined(TARGET_OS_MAC) # if __APPLE__ && TARGET_OS_MAC #define SDL_APPLE # endif #endif /********************** * TYPEDEFS **********************/ /********************** * STATIC PROTOTYPES **********************/ static void hal_init(void); static int tick_thread(void * data); static void memory_monitor(lv_task_t * param); /********************** * STATIC VARIABLES **********************/ /********************** * MACROS **********************/ /********************** * GLOBAL FUNCTIONS **********************/ int main(int argc, char ** argv) { (void) argc; /*Unused*/ (void) argv; /*Unused*/ /*Initialize LittlevGL*/ lv_init(); /*Initialize the HAL (display, input devices, tick) for LittlevGL*/ hal_init(); /*Create a demo*/ demo_create(); /*Try the benchmark to see how fast your GUI is*/ // benchmark_create(); /*Check the themes too*/ // lv_test_theme_1(lv_theme_night_init(15, NULL)); // lv_test_theme_2(); /*Try the touchpad-less navigation (use the Tab and Arrow keys or the Mousewheel)*/ // lv_test_group_1(); while(1) { /* Periodically call the lv_task handler. * It could be done in a timer interrupt or an OS task too.*/ lv_task_handler(); usleep(5 * 1000); #ifdef SDL_APPLE SDL_Event event; while(SDL_PollEvent(&event)) { #if USE_MOUSE != 0 mouse_handler(&event); #endif #if USE_KEYBOARD keyboard_handler(&event); #endif #if USE_MOUSEWHEEL != 0 mousewheel_handler(&event); #endif } #endif } return 0; } lv_res_t ICON_LVGL_runLength_info(lv_img_decoder_t * decoder, const void * src, lv_img_header_t * header) { (void)decoder; /*Unused*/ lv_img_src_t src_type = lv_img_src_get_type(src); if(src_type == LV_IMG_SRC_VARIABLE) { lv_img_cf_t cf = ((lv_img_dsc_t *)src)->header.cf; if(cf != LV_IMG_CF_USER_ENCODED_0) return LV_RES_INV; header->w = ((lv_img_dsc_t *)src)->header.w; header->h = ((lv_img_dsc_t *)src)->header.h; header->cf = ((lv_img_dsc_t *)src)->header.cf; return LV_RES_OK; } else { return LV_RES_INV; } } /********************** * STATIC FUNCTIONS **********************/ /** * Initialize the Hardware Abstraction Layer (HAL) for the Littlev graphics library */ static void hal_init(void) { /* Use the 'monitor' driver which creates window on PC's monitor to simulate a display*/ monitor_init(); /*Create a display buffer*/ static lv_disp_buf_t disp_buf1; static lv_color_t buf1_1[480*10]; lv_disp_buf_init(&disp_buf1, buf1_1, NULL, 480*10); /*Create a display*/ lv_disp_drv_t disp_drv; lv_disp_drv_init(&disp_drv); /*Basic initialization*/ disp_drv.buffer = &disp_buf1; disp_drv.flush_cb = monitor_flush; /*Used when `LV_VDB_SIZE != 0` in lv_conf.h (buffered drawing)*/ // disp_drv.hor_res = 200; // disp_drv.ver_res = 100; lv_disp_drv_register(&disp_drv); /* Add the mouse as input device * Use the 'mouse' driver which reads the PC's mouse*/ mouse_init(); lv_indev_drv_t indev_drv; lv_indev_drv_init(&indev_drv); /*Basic initialization*/ indev_drv.type = LV_INDEV_TYPE_POINTER; indev_drv.read_cb = mouse_read; /*This function will be called periodically (by the library) to get the mouse position and state*/ lv_indev_t * mouse_indev = lv_indev_drv_register(&indev_drv); /*Set a cursor for the mouse*/ LV_IMG_DECLARE(mouse_cursor_icon); /*Declare the image file.*/ lv_obj_t * cursor_obj = lv_img_create(lv_disp_get_scr_act(NULL), NULL); /*Create an image object for the cursor */ lv_img_set_src(cursor_obj, &mouse_cursor_icon); /*Set the image source*/ lv_indev_set_cursor(mouse_indev, cursor_obj); /*Connect the image object to the driver*/ /* Tick init. * You have to call 'lv_tick_inc()' in periodically to inform LittelvGL about how much time were elapsed * Create an SDL thread to do this*/ SDL_CreateThread(tick_thread, "tick", NULL); /* Optional: * Create a memory monitor task which prints the memory usage in periodically.*/ lv_task_create(memory_monitor, 3000, LV_TASK_PRIO_MID, NULL); } /** * A task to measure the elapsed time for LittlevGL * @param data unused * @return never return */ static int tick_thread(void * data) { (void)data; while(1) { SDL_Delay(5); /*Sleep for 5 millisecond*/ lv_tick_inc(5); /*Tell LittelvGL that 5 milliseconds were elapsed*/ } return 0; } /** * Print the memory usage periodically * @param param */ static void memory_monitor(lv_task_t * param) { (void) param; /*Unused*/ lv_mem_monitor_t mon; lv_mem_monitor(&mon); printf("used: %6d (%3d %%), frag: %3d %%, biggest free: %6d\n", (int)mon.total_size - mon.free_size, mon.used_pct, mon.frag_pct, (int)mon.free_biggest_size); }
the Whole project code be seen at this github link:
https://github.com/qt-raspberry/lvgl_qt_demo
SO when i change the kit to raspberry kit i get
Configuration Failed
error in cmake build part of project sidebar part of QT Creator as you can see :and the
build and run
buttons are not active.So why this happened and how could be solved?
Thanks.
-
@SoheilSabz said in Cmake Configuration for Qt Cross Compilation at Raspberry Zero:
Configuration Failed
Please show the output in "General Messages" tab after running CMake, else we can only guess.
-
@jsulm For me qmake projects works fine but CMake projects failed because of the following error:
FAILED: Raspberrydemo
: && /opt/qt5pi/gcc-linaro-7.5.0-2019.12-x86_64_arm-linux-gnueabihf/bin/arm-linux-gnueabihf-g++ -g CMakeFiles/Raspberrydemo.dir/Raspberrydemo_autogen/mocs_compilation.cpp.o CMakeFiles/Raspberrydemo.dir/main.cpp.o CMakeFiles/Raspberrydemo.dir/Raspberrydemo_autogen/EWIEGA46WW/qrc_qml.cpp.o -o Raspberrydemo -Wl,-rpath,/opt/qt5pi/sysroot/usr/local/qt5pi/lib /opt/qt5pi/sysroot/usr/local/qt5pi/lib/libQt5Quick.so.5.15.2 /opt/qt5pi/sysroot/usr/local/qt5pi/lib/libQt5Gui.so.5.15.2 /opt/qt5pi/sysroot/usr/local/qt5pi/lib/libQt5QmlModels.so.5.15.2 /opt/qt5pi/sysroot/usr/local/qt5pi/lib/libQt5Qml.so.5.15.2 /opt/qt5pi/sysroot/usr/local/qt5pi/lib/libQt5Network.so.5.15.2 /opt/qt5pi/sysroot/usr/local/qt5pi/lib/libQt5Core.so.5.15.2 && :
/opt/qt5pi/gcc-linaro-7.5.0-2019.12-x86_64_arm-linux-gnueabihf/bin/../lib/gcc/arm-linux-gnueabihf/7.5.0/../../../../arm-linux-gnueabihf/bin/ld: warning: libGLESv2.so.2, needed by /opt/qt5pi/sysroot/usr/local/qt5pi/lib/libQt5Quick.so.5.15.2, not found (try using -rpath or -rpath-link)
/opt/qt5pi/gcc-linaro-7.5.0-2019.12-x86_64_arm-linux-gnueabihf/bin/../lib/gcc/arm-linux-gnueabihf/7.5.0/../../../../arm-linux-gnueabihf/bin/ld: warning: libpng16.so.16, needed by /opt/qt5pi/sysroot/usr/local/qt5pi/lib/libQt5Gui.so.5.15.2, not found (try using -rpath or -rpath-link)
/opt/qt5pi/gcc-linaro-7.5.0-2019.12-x86_64_arm-linux-gnueabihf/bin/../lib/gcc/arm-linux-gnueabihf/7.5.0/../../../../arm-linux-gnueabihf/bin/ld: warning: libz.so.1, needed by /opt/qt5pi/sysroot/usr/local/qt5pi/lib/libQt5Gui.so.5.15.2, not found (try using -rpath or -rpath-link)
/opt/qt5pi/gcc-linaro-7.5.0-2019.12-x86_64_arm-linux-gnueabihf/bin/../lib/gcc/arm-linux-gnueabihf/7.5.0/../../../../arm-linux-gnueabihf/bin/ld: warning: libharfbuzz.so.0, needed by /opt/qt5pi/sysroot/usr/local/qt5pi/lib/libQt5Gui.so.5.15.2, not found (try using -rpath or -rpath-link)
/opt/qt5pi/gcc-linaro-7.5.0-2019.12-x86_64_arm-linux-gnueabihf/bin/../lib/gcc/arm-linux-gnueabihf/7.5.0/../../../../arm-linux-gnueabihf/bin/ld: warning: libdouble-conversion.so.1, needed by /opt/qt5pi/sysroot/usr/local/qt5pi/lib/libQt5Core.so.5.15.2, not found (try using -rpath or -rpath-link)
/opt/qt5pi/gcc-linaro-7.5.0-2019.12-x86_64_arm-linux-gnueabihf/bin/../lib/gcc/arm-linux-gnueabihf/7.5.0/../../../../arm-linux-gnueabihf/bin/ld: warning: libicui18n.so.63, needed by /opt/qt5pi/sysroot/usr/local/qt5pi/lib/libQt5Core.so.5.15.2, not found (try using -rpath or -rpath-link)
/opt/qt5pi/gcc-linaro-7.5.0-2019.12-x86_64_arm-linux-gnueabihf/bin/../lib/gcc/arm-linux-gnueabihf/7.5.0/../../../../arm-linux-gnueabihf/bin/ld: warning: libicuuc.so.63, needed by /opt/qt5pi/sysroot/usr/local/qt5pi/lib/libQt5Core.so.5.15.2, not found (try using -rpath or -rpath-link)
/opt/qt5pi/gcc-linaro-7.5.0-2019.12-x86_64_arm-linux-gnueabihf/bin/../lib/gcc/arm-linux-gnueabihf/7.5.0/../../../../arm-linux-gnueabihf/bin/ld: warning: libicudata.so.63, needed by /opt/qt5pi/sysroot/usr/local/qt5pi/lib/libQt5Core.so.5.15.2, not found (try using -rpath or -rpath-link)
/opt/qt5pi/gcc-linaro-7.5.0-2019.12-x86_64_arm-linux-gnueabihf/bin/../lib/gcc/arm-linux-gnueabihf/7.5.0/../../../../arm-linux-gnueabihf/bin/ld: warning: libpcre2-16.so.0, needed by /opt/qt5pi/sysroot/usr/local/qt5pi/lib/libQt5Core.so.5.15.2, not found (try using -rpath or -rpath-link)
/opt/qt5pi/gcc-linaro-7.5.0-2019.12-x86_64_arm-linux-gnueabihf/bin/../lib/gcc/arm-linux-gnueabihf/7.5.0/../../../../arm-linux-gnueabihf/bin/ld: warning: libgthread-2.0.so.0, needed by /opt/qt5pi/sysroot/usr/local/qt5pi/lib/libQt5Core.so.5.15.2, not found (try using -rpath or -rpath-link)
/opt/qt5pi/gcc-linaro-7.5.0-2019.12-x86_64_arm-linux-gnueabihf/bin/../lib/gcc/arm-linux-gnueabihf/7.5.0/../../../../arm-linux-gnueabihf/bin/ld: warning: libglib-2.0.so.0, needed by /opt/qt5pi/sysroot/usr/local/qt5pi/lib/libQt5Core.so.5.15.2, not found (try using -rpath or -rpath-link)FYI: I have followed https://github.com/PhysicsX/QTonRaspberryPi/blob/main/qt5.14.2onRaspberrypi tutorial for crosscompiling.