如何使用cmake和qt 6.7.3为qt快速应用程序构建yocto配方

问题描述 投票:0回答:1

我使用 qt 6.7.3 在 QT Creator 中使用 CMake 创建了一个 QT 快速应用程序。

现在,我想使用此应用程序为 stm32mp157f-dk2 创建嵌入式 Linux 映像。 我使用的是 Ubuntu 22.04 的虚拟机,并使用 v6.7.3.xml 清单设置 yocto 目录。然后,我添加了meta-st层。

然后,在我的自定义图层内,我创建了一个如下所示的食谱:

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/
}

这些是“file”文件夹中的文件

Backendsensors.cpp 
assets/    
Backendsensors.h
brushfactory.cpp
main.cpp
CMakeLists.txt     
Main.qml            
brushfactory.h

我尝试用“bitbake mygui”构建这个食谱,但我收到了错误

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

当我拨打

cmake --version
时,我得到 3.22,所以它就在那里。

我已经尝试过不同版本的食谱,但到目前为止还没有成功。

/编辑/

问题的一部分似乎是我错过了“inherit qt6-cmake”。我添加了它,构建继续,但出现另一个错误“qtcharts”未找到。我将其添加到依赖项中并修复了该错误。
现在,还有另一个错误,说找不到“main.cpp”文件,甚至在文件夹中也找不到“main.cpp”文件。

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.
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.

CMakelist.txt 文件是由 qt Creator 直接创建的文件,我刚刚在 qt Creator 中运行了该应用程序,它运行良好,所以我想它找到了 main.cpp

qt embedded-linux yocto yocto-recipe
1个回答
0
投票

我终于能够烘焙食谱了:) 问题是我需要使用 SRC_URI += 或 SRC_URI = 然后, 我在另一篇文章中读到,qt6-cmake 添加了资产,而无需明确告诉它这样做,但我必须使用 SRC_URI =+ 添加它们,因为没有找到它们。 然后,我写错了,就是这样,食谱烘焙成功了:)

© www.soinside.com 2019 - 2024. All rights reserved.