Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/css/38.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Yocto 为QT5应用程序创建配方_Yocto - Fatal编程技术网

Yocto 为QT5应用程序创建配方

Yocto 为QT5应用程序创建配方,yocto,Yocto,我已经挣扎太久了,所以我需要帮助:) 我制作了一个大型QT5.8应用程序,通常当我想用PC编译它时,我只需运行以下命令:qmake-qt=5.9-spec linux-arm-gnueabihf-g++-config configuration_name。 通过这个命令,我可以使用linux-arm-gnueabihf-g++工具链交叉编译armhf体系结构的源代码 但是现在,由于我可以很容易地为我的目标(Raspberry pi)创建一个yocto图像,我想制作一个配方,以便编译我的qt软件并

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

我制作了一个大型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获取源(确定)
  • 打开包装->好的
之后,我想执行qmake命令以生成我的makefile,但我的问题是:/

首先,我使用

require recipes-qt/qt5/qt5.inc
然后我尝试了很多东西

将“qmake”写入do\u 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
}
谢谢

简短的回答 长话短说 下面是我如何添加QT项目的示例。它不是在使用git,而是在使用本地文件。然而,为了更进一步,我建议:

  • 用我的方式作为测试。将QT项目复制到/yocto/local\u sources/Myproject/ 并通过使用fileextrapaths\u prepend\u(如下所示)让Yocto知道这一点

  • 如果这在您的环境中起作用,请根据您的需要调整它(例如,从git而不是本地源代码构建,这是最好的选择。)

这种方法已经过测试,并且对于以后使用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

如果您需要指定额外的qamke选项,则不需要覆盖
do\u configure
,请通过
EXTRA\u QMAKEVARS\u PRE='X=Y….'
感谢您的回复,我会这样做。无论如何,即使没有“do_compile”重写,qmake也永远不会执行确保
S
变量指向sourcedir的顶部,默认值可能不正确,因此您可能需要调整配方中的变量,理想情况下,也不需要重写
do_fetch
,您可以简单地使用
SRC_URI=“git://${USERNAME}:${PASSWORD}@gitlab….;protocol=ssh“
然后设置
S=“${WORKDIR}/git”
您还需要设置
SRCREV=“您的repo中的一些git-SHA值”
#
# 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