How to create recipe for QT quick app in yocto
-
Hi there QT community!
I create a QT quick app in QT Creator with CMake using qt 6.7.3.
Now, I would like to create an embedded Linux image with this app for the stm32mp157f-dk2.
I'm using a VM with Ubuntu 22.04 and set up the yocto directory with the v6.7.3.xml manifest. Then, I added the meta-st layer.Then, inside my custom layer, I created a recipe that looks like this:
SUMMARY = "This is the GUI for Hespect Software medical device" DESCRIPTION = "Recipe created by bitbake-layers" LICENSE = "CLOSED" SECTION = "Mysection" DEPENDS += "qtbase" RDEPENDS_${PN} += "qtwayland" SRC_URI = "file://Backendsensors.h" SRC_URI = "file://Backendsensors.cpp" SRC_URI = "file://brushfactory.h" SRC_URI = "file://brushfactory.cpp" SRC_URI = "file://main.cpp" SRC_URI = "file://Main.qml" SRC_URI = "file://CMakeLists.txt" S = "${WORKDIR}" do_compile () { cmake -DCMAKE_TOOLCHAIN_FILE=${STAGING_DIR_NATIVE}/usr/share/cmake/OEToolchain.cmake ${S} make } do_install () { install -d ${D}/usr/share/mygui/ install -m 0644 ${S}/assets/images/* ${D}/usr/share/mygui/assets/images/ install -m 0644 ${S}/Backendsensors.h ${D}/usr/include/ install -m 0644 ${S}/Backendsensors.cpp ${D}/usr/src/mygui/ install -m 0644 ${S}/brushfactory.h ${D}/usr/include/ install -m 0644 ${S}/brushfactory.cpp ${D}/usr/src/mygui/ install -m 0644 ${S}/main.cpp ${D}/usr/src/mygui/ install -m 0644 ${S}/Main.qml ${D}/usr/share/mygui/ install -m 0755 ${B}/main ${D}/usr/bin/ }
These are the files inside the "file" folder
Backendsensors.cpp assets/ Backendsensors.h brushfactory.cpp main.cpp CMakeLists.txt Main.qml brushfactory.h
I tried building this recipe with "bitbake mygui" but I got the error
ERROR: mygui-0-r0 do_compile: ExecutionError('/home/vboxuser/yocto/build-stm32mp15-disco/tmp/work/cortexa7t2hf-neon-vfpv4-poky-linux-gnueabi/mygui/0/temp/run.do_compile.8991', 127, None, None) ERROR: Logfile of failure stored in: /home/vboxuser/yocto/build-stm32mp15-disco/tmp/work/cortexa7t2hf-neon-vfpv4-poky-linux-gnueabi/mygui/0/temp/log.do_compile.8991 Log data follows: | DEBUG: Executing shell function do_compile | /home/vboxuser/yocto/build-stm32mp15-disco/tmp/work/cortexa7t2hf-neon-vfpv4-poky-linux-gnueabi/mygui/0/temp/run.do_compile.8991: 141: cmake: not found | WARNING: exit code 127 from a shell command. ERROR: Task (/home/vboxuser/yocto/build-stm32mp15-disco/meta-custom/recipes-software/myGUI/mygui_0_1.bb:do_compile) failed with exit code '1' NOTE: Tasks Summary: Attempted 3568 tasks of which 3567 didn't need to be rerun and 1 failed. Summary: 1 task failed: /home/vboxuser/yocto/build-stm32mp15-disco/meta-custom/recipes-software/myGUI/mygui_0_1.bb:do_compile Summary: There was 1 ERROR message, returning a non-zero exit code
When I call cmake --version I get 3.22, so it's there.
Any help is sincerely appreciated :)
-
I was finally able to bitbake the recipe :)
The problem was that I needed to use SRC_URI +=, instead or SRC_URI =Then, I read on another post that qt6-cmake add the assets without needing to explicitly tell it to do it, but I had to add them with SRC_URI =+ because they weren't being found.
Then, I had a typo and that was it, the recipe bake successfully :)
-
-
Hi @Ronel_qtmaster , thanks for the quick reply.
My project is based on CMake, so I don't have the ".pro" file.
Also, I'm using meta-qt6 which seems to be the last release. Is that a problem or should I use meta-qt5 with QMake?
-
Hi,
From a very quick search, aren't you missing something like
inherit cmake
in your recipe ?You have to tell Yocto that you require this tool to build your application.
-
Hi @SGaist , I missed "inherit qt6-cmake" and that seems to help because the build continued. At the end of the build I had a qtchart problem because it wasn't being found but it seems I fixed it in the depends.
Now, it seems my build doesn't find the "main.cpp" even though it's in the "file" folder.
CMake Error at recipe-sysroot/usr/lib/cmake/Qt6Core/Qt6CoreMacros.cmake:634 (add_executable): | Cannot find source file: | | main.cpp | | Tried extensions .c .C .c++ .cc .cpp .cxx .cu .mpp .m .M .mm .ixx .cppm | .ccm .cxxm .c++m .h .hh .h++ .hm .hpp .hxx .in .txx .f .F .for .f77 .f90 | .f95 .f03 .hip .ispc | Call Stack (most recent call first): | recipe-sysroot/usr/lib/cmake/Qt6Core/Qt6CoreMacros.cmake:575 (_qt_internal_create_executable) | recipe-sysroot/usr/lib/cmake/Qt6Core/Qt6CoreMacros.cmake:875 (qt6_add_executable) | CMakeLists.txt:11 (qt_add_executable) | | | -- Generating done (0.0s) | CMake Warning: | Manually-specified variables were not used by the project: | | CMAKE_EXPORT_NO_PACKAGE_REGISTRY | FETCHCONTENT_FULLY_DISCONNECTED | INSTALL_ARCHDATADIR | INSTALL_BINDIR | INSTALL_DATADIR | INSTALL_DESCRIPTIONSDIR | INSTALL_DOCDIR | INSTALL_EXAMPLESDIR | INSTALL_INCLUDEDIR | INSTALL_LIBDIR | INSTALL_LIBEXECDIR | INSTALL_MKSPECSDIR | INSTALL_PLUGINSDIR | INSTALL_QMLDIR | INSTALL_SYSCONFDIR | INSTALL_TESTSDIR | INSTALL_TRANSLATIONSDIR | LIB_SUFFIX | PYTHON_EXECUTABLE | Python3_EXECUTABLE | Python_EXECUTABLE | QT_BUILD_INTERNALS_NO_FORCE_SET_INSTALL_PREFIX | QT_CMAKE_DEBUG_EXTEND_TARGET | QT_FORCE_BUILD_TOOLS | __harfbuzz_broken_config_file | | | CMake Generate step failed. Build files cannot be regenerated correctly. | WARNING: exit code 1 from a shell command. ERROR: Task (/home/vboxuser/yocto/build-stm32mp15-disco/meta-custom/recipes-software/myGUI/mygui_0_1.bb:do_configure) failed with exit code '1' NOTE: Tasks Summary: Attempted 3853 tasks of which 3829 didn't need to be rerun and 1 failed. NOTE: Build completion summary: NOTE: do_populate_sysroot: 0.0% sstate reuse(0 setscene, 1 scratch) NOTE: do_deploy_source_date_epoch: 0.0% sstate reuse(0 setscene, 2 scratch) NOTE: do_create_spdx: 0.0% sstate reuse(0 setscene, 1 scratch) NOTE: do_create_runtime_spdx: 0.0% sstate reuse(0 setscene, 1 scratch) NOTE: do_package_qa: 0.0% sstate reuse(0 setscene, 1 scratch) NOTE: do_recipe_qa: 0.0% sstate reuse(0 setscene, 1 scratch) NOTE: do_package: 0.0% sstate reuse(0 setscene, 1 scratch) NOTE: do_packagedata: 0.0% sstate reuse(0 setscene, 1 scratch) NOTE: do_package_write_ipk: 99.0% sstate reuse(95 setscene, 1 scratch) NOTE: do_populate_lic: 0.0% sstate reuse(0 setscene, 1 scratch) Summary: 1 task failed: /home/vboxuser/yocto/build-stm32mp15-disco/meta-custom/recipes-software/myGUI/mygui_0_1.bb:do_configure Summary: There was 1 WARNING message. Summary: There was 1 ERROR message, returning a non-zero exit code.
-
Is it the only file it's complaining about ?
-
Hi @SGaist , I tried a clean build to fix the qtcharts and the "inherit qt6-cmake" and it results on the same output, but it doesn't matter the order of the SRC_URI, it complains about the "CMakeLists.txt" file
| DEBUG: Python function extend_recipe_sysroot finished | DEBUG: Executing shell function do_configure | CMake Warning: | Ignoring extra path from command line: | | "/home/vboxuser/yocto/build-stm32mp15-disco/tmp/work/cortexa7t2hf-neon-vfpv4-poky-linux-gnueabi/mygui/0" | | | CMake Error: The source directory "/home/vboxuser/yocto/build-stm32mp15-disco/tmp/work/cortexa7t2hf-neon-vfpv4-poky-linux-gnueabi/mygui/0" does not appear to contain CMakeLists.txt. | Specify --help for usage, or press the help button on the CMake GUI. | WARNING: exit code 1 from a shell command. ERROR: Task (/home/vboxuser/yocto/build-stm32mp15-disco/meta-custom/recipes-software/myGUI/mygui_0_1.bb:do_configure) failed with exit code '1' NOTE: Tasks Summary: Attempted 3857 tasks of which 3855 didn't need to be rerun and 1 failed. NOTE: Build completion summary: NOTE: do_create_spdx: 0.0% sstate reuse(0 setscene, 1 scratch) Summary: 1 task failed: /home/vboxuser/yocto/build-stm32mp15-disco/meta-custom/recipes-software/myGUI/mygui_0_1.bb:do_configure Summary: There was 1 ERROR message, returning a non-zero exit code.
The file is under recipes/files/CMakeLists.txt.
I'm using "file://CMakeLists.txt" because I saw it on a youtube video where it's working. Notice the difference between file and files. But, even if I use files in SRC_URI it doesn't work -
Can you show your CMakeLists.txt ?
-
It's the same one created by the QT creator. I can run the app in qt Creator so the file works in CMake
CMakeLists.txtcmake_minimum_required(VERSION 3.16) project(medical-device-qt VERSION 0.1 LANGUAGES CXX) set(CMAKE_CXX_STANDARD_REQUIRED ON) find_package(Qt6 6.5 REQUIRED COMPONENTS Quick Charts) qt_standard_project_setup(REQUIRES 6.5) qt_add_executable(appmedical-device-qt main.cpp Backendsensors.h Backendsensors.cpp brushfactory.h brushfactory.cpp ) qt_add_qml_module(appmedical-device-qt URI medical-device-qt VERSION 1.0 QML_FILES Main.qml RESOURCES assets/images/battery-full.svg assets/images/battery-mid.svg assets/images/battery-low.svg assets/images/rss-full.svg assets/images/rss-mid.svg assets/images/rss-low.svg assets/images/signal-full.svg assets/images/signal-mid.svg assets/images/signal-low.svg SOURCES Backendsensors.h Backendsensors.cpp brushfactory.h brushfactory.cpp ) # Qt for iOS sets MACOSX_BUNDLE_GUI_IDENTIFIER automatically since Qt 6.1. # If you are developing for iOS or macOS you should consider setting an # explicit, fixed bundle identifier manually though. set_target_properties(appmedical-device-qt PROPERTIES # MACOSX_BUNDLE_GUI_IDENTIFIER com.example.appmedical-device-qt MACOSX_BUNDLE_BUNDLE_VERSION ${PROJECT_VERSION} MACOSX_BUNDLE_SHORT_VERSION_STRING ${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR} MACOSX_BUNDLE TRUE WIN32_EXECUTABLE TRUE ) target_link_libraries(appmedical-device-qt PRIVATE Qt6::Quick Qt6::Charts ) include(GNUInstallDirs) install(TARGETS appmedical-device-qt BUNDLE DESTINATION . LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} )
mygui_0.1.bb
SUMMARY = "This is the GUI for Hespect Software medical device" DESCRIPTION = "Recipe created by bitbake-layers" LICENSE = "CLOSED" SECTION = "Mysection" DEPENDS += " qtbase \ qtdeclarative-native \ qtdeclarative \ qtquick3d \ qtcharts" RDEPENDS_${PN} += "qtwayland" EXTRA_OECMAKE += "-DCMAKE_PREFIX_PATH=${STAGING_DIR_HOST}${prefix}" SRC_URI = "file://main.cpp" SRC_URI = "file://CMakeLists.txt" SRC_URI = "file://CMakeLists.txt.user" SRC_URI = "file://Backendsensors.h" SRC_URI = "file://Backendsensors.cpp" SRC_URI = "file://brushfactory.h" SRC_URI = "file://brushfactory.cpp" SRC_URI = "file://Main.qml" S = "${WORKDIR}" inherit qt6-cmake inherit populate_sdk_qt6
-
I was finally able to bitbake the recipe :)
The problem was that I needed to use SRC_URI +=, instead or SRC_URI =Then, I read on another post that qt6-cmake add the assets without needing to explicitly tell it to do it, but I had to add them with SRC_URI =+ because they weren't being found.
Then, I had a typo and that was it, the recipe bake successfully :)
-
-
Nice ! Thanks for the feedback ! :-)
Happy coding -