【问题标题】:Create a recipe for a QT5 application为 QT5 应用程序创建配方
【发布时间】:2020-09-30 23:14:33
【问题描述】:

我已经挣扎太久了,所以我需要帮助:)

我制作了一个大型 QT5.8 应用程序,通常当我想用我的 PC 编译它时,我只需要运行以下命令:qmake -qt=5.9 -spec linux-arm-gnueabihf-g++ -config configuration_name。 通过这个命令,我可以使用 linux-arm-gnueabihf-g++ 工具链交叉编译我的 armhf 架构的源代码。

但是现在,可以轻松地为我的目标(Raspberry pi)创建一个 yocto 映像,我想制作一个配方来编译我的 qt 软件并将其放入我的映像中。 目前,我成功地在我的食谱中完成了以下任务:

  • do_fetch -> Yocto 从 git repo 获取源代码(OK)
  • do_unpack -> 好的

之后我想执行一个 qmake 命令来生成我的 makefile,但这是我的问题:/

首先,我使用

在我的食谱中包含了 qmake5 类
require recipes-qt/qt5/qt5.inc

然后我尝试了很多东西..

将“qmake”写入 do_configure 任务不起作用。我尝试的最后一件事是:'${OE_QMAKE_QMAKE} ${S}/my_software.pro -config my_config' 但仍然是同样的错误:

Could not find qmake spec 'linux-oe-g++'

我不知道该怎么做,也找不到任何食谱示例来做我想做的事情。 如果有人已经遇到过这个问题或有使用 yocto 配方编译 qt5 软件的经验,我希望得到您的帮助:)

我的食谱:

LICENSE = "CLOSED"
LIC_FILES_CHKSUM = " "
USERNAME = "****"
PASSWORD = "*****"
S = "${WORKDIR}/git"

require recipes-qt/qt5/qt5.inc

do_fetch(){
git clone http://${USERNAME}:${PASSWORD}@gitlab.....  
}

do_configure () {
${OE_QMAKE_QMAKE} ${S}/my_software.pro -config my_config
}

谢谢

【问题讨论】:

  • 如果您需要指定额外的 qamke 选项,则不需要覆盖 do_configure,通过 EXTRA_QMAKEVARS_PRE = 'X=Y.....' 传递它们
  • 感谢您的回复,我会做的。无论如何,即使没有“do_compile”覆盖,qmake 也永远不会执行
  • 确保 S 变量指向您的源目录的顶部,默认值可能不正确,因此您可能需要调整配方中的变量,理想情况下也不需要覆盖 do_fetch,你可以简单地使用SRC_URI = "git://${USERNAME}:${PASSWORD}@gitlab.....;protocol=ssh"然后设置S = "${WORKDIR}/git "你还需要设置SRCREV = "some git SHA value from your repo"

标签: yocto


【解决方案1】:

简答

Add "inherit qmake5" and let Yocto take care of it :)

长答案

这是我如何添加 QT 项目的示例。它不是使用 git,而是使用本地文件。但是,为了更进一步,我建议:

  • 用我的方式作为测试。将 QT 项目复制到 /yocto/local_sources/Myproject/ 并使用 FILESEXTRAPATHS_prepend_ 让 Yocto 知道这一点(如下所示)。

  • 如果这适用于您的环境,请根据您的需要进行调整(例如,从 git 构建而不是 local_source,这当然更好。)

这种方式经过测试,也适用于以后使用 qt-creator 和 yocto SDK 进行远程调试。坚持使用 Yocto,最终还是值得的。

这是我的 .bb 文件:

#
# Build QT xyz application
#

SUMMARY = "..."
SECTION = "Mysection"
LICENSE = "CLOSED"

#Add whatever you need here
DEPENDS += "qtbase qtmultimedia qtsvg"

#Add here your .pro and all other relevant files (if you use git later this step will be less tedious ...)
SRC_URI += "file://Myproject.pro"
SRC_URI += "file://*.h"
SRC_URI += "file://*.cpp"
SRC_URI += "file://subdir1/*.h"
SRC_URI += "file://subdir1/*.cpp"
SRC_URI += "file://subdir2/*.h"
SRC_URI += "file://subdir2/*.cpp"
SRC_URI += "file://subdir2/subdir3/*.h"
SRC_URI += "file://subdir2/subdir3/*.cpp"

#If you need autostart:
#SRC_URI += "file://myproject.service"

#Register for root file system aggregation
FILES_${PN} += "${bindir}/Myproject"

#RBE todo: both needed ?
FILESEXTRAPATHS_prepend_${PN} := "/yocto/local_sources/Myproject/Src:"
FILESEXTRAPATHS_prepend := "/yocto/local_sources/Myproject/Src:"

S = "${WORKDIR}"

#If you want to auto-start this add:
#SYSTEMD_SERVICE_${PN} = "Myproject.service"

FILES_${PN} = "${datadir} ${bindir} ${systemd_unitdir}"
FILES_${PN}-dbg = "${datadir}/${PN}/.debug"
FILES_${PN}-dev = "/usr/src"

#Check what's needed in your case ...
RDEPENDS_${PN} += "\
    qtmultimedia-qmlplugins \
    qtvirtualkeyboard \
    qtquickcontrols2-qmlplugins \
    gstreamer1.0-libav \
    gstreamer1.0-plugins-base-audioconvert \
    gstreamer1.0-plugins-base-audioresample \
    gstreamer1.0-plugins-base-playback \
    gstreamer1.0-plugins-base-typefindfunctions \
    gstreamer1.0-plugins-base-videoconvert \
    gstreamer1.0-plugins-base-videoscale \
    gstreamer1.0-plugins-base-volume \
    gstreamer1.0-plugins-base-vorbis \
    gstreamer1.0-plugins-good-autodetect \
    gstreamer1.0-plugins-good-matroska \
    gstreamer1.0-plugins-good-ossaudio \
    gstreamer1.0-plugins-good-videofilter \
"

do_install_append () {

    # Install application
    install -d ${D}${bindir}
    install -m 0755 Myproject ${D}${bindir}/

    # Uncomment if you want to autostart this application as a service     
    #install -Dm 0644 ${WORKDIR}/myproject.service ${D}${systemd_system_unitdir}/myproject.service

    # Install resource files (example)
    #install -d ${D}${datadir}/${PN}/Images
    #for f in ${S}/Images/*; do \
    #    install -Dm 0644 $f ${D}${datadir}/${PN}/Images/
    #done
}

#Also inherit "systemd" if you need autostart
inherit qmake5

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2016-10-27
    • 2013-03-27
    • 2013-02-19
    • 1970-01-01
    • 1970-01-01
    • 2018-10-26
    • 2011-11-30
    • 2014-12-10
    相关资源
    最近更新 更多