Yocto/Qt5.6:无法构建示例 Qt 应用程序

Posted

技术标签:

【中文标题】Yocto/Qt5.6:无法构建示例 Qt 应用程序【英文标题】:Yocto/Qt5.6: Unable to build a sample Qt Application 【发布时间】:2017-03-06 14:03:49 【问题描述】:

我有一个可以在 Yocto Krogoth-next 上使用 core-image-sato 构建的 Nitrogen6x 板。我已经安装了 Qt Creator 3.5.1(基于 Qt 5.5.1),并且按照[Build & Install Qt5 toolchain] 文档添加了我的氮气板套件。我添加了一个示例 Qt Quick Application,其中组件集选择为 Qt Quick 2.1,并尝试编译源代码,我注意到以下错误。

19:04:25: Running steps for project untitled6...
19:04:25: Starting: "/opt/poky/2.1.1/sysroots/i686-pokysdk-linux/usr/bin/qt5/qmake" /home/test/untitled6/untitled6.pro -r -spec linux-g++
19:04:25: The process "/opt/poky/2.1.1/sysroots/i686-pokysdk-linux/usr/bin/qt5/qmake" exited normally.
19:04:25: Starting: "/usr/bin/make" 
g++ -c -pipe -O2 -std=gnu++0x -Wall -W -D_REENTRANT -fPIC -DQT_NO_DEBUG -DQT_QUICK_LIB -DQT_GUI_LIB -DQT_QML_LIB -DQT_NETWORK_LIB -DQT_CORE_LIB -I../untitled6 -I. -isystem /opt/poky/2.1.1/sysroots/cortexa9hf-neon-poky-linux-gnueabi/usr/include/qt5 -isystem /opt/poky/2.1.1/sysroots/cortexa9hf-neon-poky-linux-gnueabi/usr/include/qt5/QtQuick -isystem /opt/poky/2.1.1/sysroots/cortexa9hf-neon-poky-linux-gnueabi/usr/include/qt5/QtGui -isystem /opt/poky/2.1.1/sysroots/cortexa9hf-neon-poky-linux-gnueabi/usr/include/qt5/QtQml -isystem /opt/poky/2.1.1/sysroots/cortexa9hf-neon-poky-linux-gnueabi/usr/include/qt5/QtNetwork -isystem /opt/poky/2.1.1/sysroots/cortexa9hf-neon-poky-linux-gnueabi/usr/include/qt5/QtCore -I. -I/opt/poky/2.1.1/sysroots/cortexa9hf-neon-poky-linux-gnueabi/usr/lib/qt5/mkspecs/linux-g++ -o main.o ../untitled6/main.cpp
/opt/poky/2.1.1/sysroots/i686-pokysdk-linux/usr/bin/qt5/rcc -name qml ../untitled6/qml.qrc -o qrc_qml.cpp
g++ -c -pipe -O2 -std=gnu++0x -Wall -W -D_REENTRANT -fPIC -DQT_NO_DEBUG -DQT_QUICK_LIB -DQT_GUI_LIB -DQT_QML_LIB -DQT_NETWORK_LIB -DQT_CORE_LIB -I../untitled6 -I. -isystem /opt/poky/2.1.1/sysroots/cortexa9hf-neon-poky-linux-gnueabi/usr/include/qt5 -isystem /opt/poky/2.1.1/sysroots/cortexa9hf-neon-poky-linux-gnueabi/usr/include/qt5/QtQuick -isystem /opt/poky/2.1.1/sysroots/cortexa9hf-neon-poky-linux-gnueabi/usr/include/qt5/QtGui -isystem /opt/poky/2.1.1/sysroots/cortexa9hf-neon-poky-linux-gnueabi/usr/include/qt5/QtQml -isystem /opt/poky/2.1.1/sysroots/cortexa9hf-neon-poky-linux-gnueabi/usr/include/qt5/QtNetwork -isystem /opt/poky/2.1.1/sysroots/cortexa9hf-neon-poky-linux-gnueabi/usr/include/qt5/QtCore -I. -I/opt/poky/2.1.1/sysroots/cortexa9hf-neon-poky-linux-gnueabi/usr/lib/qt5/mkspecs/linux-g++ -o qrc_qml.o qrc_qml.cpp
g++ -Wl,-O1 -o untitled6 main.o qrc_qml.o   -lQt5Quick -lQt5Gui -lQt5Qml -lQt5Network -lQt5Core -lGLESv2 -lpthread 
/usr/bin/ld: cannot find -lQt5Quick
/usr/bin/ld: cannot find -lQt5Gui
/usr/bin/ld: cannot find -lQt5Qml
/usr/bin/ld: cannot find -lQt5Network
/usr/bin/ld: cannot find -lQt5Core
/usr/bin/ld: cannot find -lGLESv2
collect2: ld returned 1 exit status
make: *** [untitled6] Error 1
19:04:26: The process "/usr/bin/make" exited with code 2.
Error while building/deploying project untitled6 (kit: Nitrogen)
When executing step 'Make'
19:04:26: Elapsed time: 00:01.

所有 Qt 库都存在于/sysroots/cortexa9hf-neon-poky-linux-gnueabi/usr/include/qt5/ 下,并且我已在我的工具包下正确设置了 sysroot 路径,但我无法弄清楚为什么我的应用程序无法引用这些库。对此的任何帮助深表感谢。提前致谢。

【问题讨论】:

【参考方案1】:

您的工具包指向的 mkspec 似乎是错误的 (linux-g++),引用自您的构建日志

-I/opt/poky/2.1.1/sysroots/cortexa9hf-neon-poky-linux-gnueabi/usr/lib/qt5/mkspecs/linux-g++

在为nitro6x 构建时,它可能应该是linux-oe-g++。这可以在您选择的 Qt 版本中默认设置,也可以通过在“mkspec”下的 QtCreator 选项中修改 Kit 本身来设置。

您看到的错误可能是由于指向的库的 ABI 和架构与您编译的 x86/64 代码不兼容。

如果遇到问题(即关于“C”未找到的编译错误),请确保在启动 QtCreator 之前获取 Yocto 的环境文件。这将设置交叉编译器的路径。示例:

source /opt/poky/1.6.2/environment-setup-cortexa9hf-vfp-neon-poky-linux-gnueabi
~/Qt/Tools/QtCreator/bin/qtcreator

【讨论】:

是的。我尝试将“Qt mkspec”作为linux-oe-g++ 添加到我的工具包中。我注意到错误make: c: Command not found。然后我尝试在#!/bin/sh 之前将source /opt/poky/2.1.1/environment-setup-cortexa9hf-neon-poky-linux-gnueabi 添加到我的~/Qt/Tools/QtCreator/bin/qtcreator.sh 脚本中,然后启动sudo sh qtcreator.sh 并尝试构建它并且它工作。非常感谢。 很高兴它有帮助:)

以上是关于Yocto/Qt5.6:无法构建示例 Qt 应用程序的主要内容,如果未能解决你的问题,请参考以下文章

Qt + Ogre3D。我无法构建一个非常简单的示例

从 ParaView 构建自定义 Qt 应用程序示例时出错

用于arm linux的QT构建应用程序

Crypto++ 无法构建 Qt 应用程序

使用 macdeployqt 构建 QSqlDatabase 的 Qt 应用程序无法正常工作

基于 MAC 10.7.4 构建的 Qt 应用程序无法在 10.6 上运行