Qt 5.6使用EGLFS对树莓派进行交叉编译

Qt 5.6 Cross Compile for Raspberry Pi with EGLFS

本文关键字:交叉编译 使用 EGLFS Qt      更新时间:2023-10-16

我在这里学习教程https://wiki.qt.io/RaspberryPi2EGLFS

我使用的是Ubuntu 15.04。在制作步骤中,我遇到了一堆未定义的参考错误,主要涉及QT方法。

.obj/qaccessible.o:qaccessible.cpp:function QAccessibleEvent::accessibleInterface() const: error: undefined reference to 'QDebug::~QDebug()'
.obj/qaccessible.o:qaccessible.cpp:function QAccessibleEvent::accessibleInterface() const: error: undefined reference to 'QDebug::~QDebug()'
.obj/qaccessible.o:qaccessible.cpp:function QAccessibleEvent::accessibleInterface() const: error: undefined reference to 'QDebug::~QDebug()'
.obj/qaccessible.o:qaccessible.cpp:function QAccessibleEvent::accessibleInterface() const: error: undefined reference to 'QDebug::~QDebug()'
.obj/qaccessible.o:qaccessible.cpp:function operator<<(QDebug, QAccessibleInterface const*): error: undefined reference to 'QDebug::putString(QChar const*, unsigned int)'
.obj/qaccessible.o:qaccessible.cpp:function operator<<(QDebug, QAccessibleInterface const*): error: undefined reference to 'QDebug::putString(QChar const*, unsigned int)'
.obj/qgenericpluginfactory.o:qgenericpluginfactory.cpp:function QGenericPluginFactory::create(QString const&, QString const&): error: undefined reference to 'QString::toLower_helper(QString const&)'
.obj/qwindowsysteminterface.o:qwindowsysteminterface.cpp:function qt_handleShortcutEvent(QObject*, unsigned long, int, QFlags<Qt::KeyboardModifier>, QString const&, bool, unsigned short): error: undefined reference to 'QCoreApplication::notifyInternal2(QObject*, QEvent*)'
.obj/qplatforminputcontextfactory.o:qplatforminputcontextfactory.cpp:function QPlatformInputContextFactory::create(QString const&): error: undefined reference to 'QString::toLower_helper(QString&)'
.obj/qplatformtheme.o:qplatformtheme.cpp:function QPlatformTheme::defaultThemeHint(QPlatformTheme::ThemeHint): error: undefined reference to 'qEnvironmentVariableIntValue(char const*, bool*)'
.obj/qplatformtheme.o:qplatformtheme.cpp:function QPlatformTheme::defaultThemeHint(QPlatformTheme::ThemeHint): error: undefined reference to 'QMetaType::registerNormalizedType(QByteArray const&, void (*)(void*), void* (*)(void*, void const*), int, QFlags<QMetaType::TypeFlag>, QMetaObject const*)'
.obj/qplatformtheme.o:qplatformtheme.cpp:function QPlatformTheme::defaultThemeHint(QPlatformTheme::ThemeHint): error: undefined reference to 'QMetaType::registerNormalizedType(QByteArray const&, void (*)(void*), void* (*)(void*, void const*), int, QFlags<QMetaType::TypeFlag>, QMetaObject const*)'
.obj/qplatformtheme.o:qplatformtheme.cpp:function QMetaTypeId<QtMetaTypePrivate::QSequentialIterableImpl>::qt_metatype_id(): error: undefined reference to 'QMetaType::registerNormalizedType(QByteArray const&, void (*)(void*), void* (*)(void*, void const*), int, QFlags<QMetaType::TypeFlag>, QMetaObject const*)'
.obj/qplatformtheme.o:qplatformtheme.cpp:function QMetaTypeId<QList<int> >::qt_metatype_id(): error: undefined reference to 'QMetaType::registerNormalizedType(QByteArray const&, void (*)(void*), void* (*)(void*, void const*), int, QFlags<QMetaType::TypeFlag>, QMetaObject const*)'
.obj/qplatformthemefactory.o:qplatformthemefactory.cpp:function QPlatformThemeFactory::create(QString const&, QString const&): error: undefined reference to 'QString::toLower_helper(QString&)'
.obj/qplatformwindow.o:qplatformwindow.cpp:function QPlatformWindow::requestUpdate(): error: undefined reference to 'qEnvironmentVariableIntValue(char const*, bool*)'
.obj/qsurfaceformat.o:qsurfaceformat.cpp:function operator<<(QDebug, QSurfaceFormat const&): error: undefined reference to 'QDebug::resetFormat()'
.obj/qguiapplication.o:qguiapplication.cpp:function QGuiApplicationPrivate::processGestureEvent(QWindowSystemInterfacePrivate::GestureEvent*): error: undefined reference to 'QCoreApplication::notifyInternal2(QObject*, QEvent*)'
.obj/qguiapplication.o:qguiapplication.cpp:function QGuiApplicationPrivate::createPlatformIntegration(): error: undefined reference to 'QString::toLower_helper(QString&)'
.obj/qguiapplication.o:qguiapplication.cpp:function updateBlockedStatusRecursion(QWindow*, bool): error: undefined reference to 'QCoreApplication::notifyInternal2(QObject*, QEvent*)'
.obj/qguiapplication.o:qguiapplication.cpp:function QGuiApplicationPrivate::showModalWindow(QWindow*): error: undefined reference to 'QCoreApplication::notifyInternal2(QObject*, QEvent*)'
.obj/qguiapplication.o:qguiapplication.cpp:function QGuiApplicationPrivate::init(): error: undefined reference to 'QDebug::putByteArray(char const*, unsigned int, QDebug::Latin1Content)'
.obj/qguiapplication.o:qguiapplication.cpp:function QGuiApplicationPrivate::init(): error: undefined reference to 'qEnvironmentVariableIntValue(char const*, bool*)'
.obj/qguiapplication.o:qguiapplication.cpp:function QGuiApplicationPrivate::init(): error: undefined reference to 'QByteArray::toLower_helper(QByteArray&)'
.obj/qguiapplication.o:qguiapplication.cpp:function QGuiApplicationPrivate::init(): error: undefined reference to 'QDebug::putString(QChar const*, unsigned int)'
.obj/qguiapplication.o:qguiapplication.cpp:function QGuiApplicationPrivate::init(): error: undefined reference to 'QString::toLower_helper(QString&)'
.obj/qwindow.o:qwindow.cpp:function operator<<(QDebug, QWindow const*): error: undefined reference to 'qt_QMetaEnum_debugOperator(QDebug&, int, QMetaObject const*, char const*)'
.obj/qwindow.o:qwindow.cpp:function operator<<(QDebug, QWindow const*): error: undefined reference to 'qt_QMetaEnum_debugOperator(QDebug&, int, QMetaObject const*, char const*)'
.obj/qwindow.o:qwindow.cpp:function operator<<(QDebug, QWindow const*): error: undefined reference to 'qt_QMetaEnum_flagDebugOperator(QDebug&, unsigned long long, QMetaObject const*, char const*)'
.obj/qwindow.o:qwindow.cpp:function operator<<(QDebug, QWindow const*): error: undefined reference to 'QDebug::putString(QChar const*, unsigned int)'
.obj/qwindow.o:qwindow.cpp:function QWindowPrivate::create(bool): error: undefined reference to 'qt_QMetaEnum_flagDebugOperator(QDebug&, unsigned long long, QMetaObject const*, char const*)'
.obj/qclipboard.o:qclipboard.cpp:function QClipboard::text(QString&, QClipboard::Mode) const: error: undefined reference to 'QString::operator=(QLatin1String)'
.obj/qcursor.o:qcursor.cpp:function operator<<(QDebug, QCursor const&): error: undefined reference to 'qt_QMetaEnum_debugOperator(QDebug&, int, QMetaObject const*, char const*)'
.obj/qdnd.o:qdnd.cpp:function imageReadMimeFormats(): error: undefined reference to 'QByteArray::toLower_helper(QByteArray const&)'
.obj/qdnd.o:qdnd.cpp:function imageWriteMimeFormats(): error: undefined reference to 'QByteArray::toLower_helper(QByteArray const&)'
.obj/qdnd.o:qdnd.cpp:function QInternalMimeData::renderDataHelper(QString const&, QMimeData const*): error: undefined reference to 'QByteArray::toUpper_helper(QByteArray&)'
.obj/qevent.o:qevent.cpp:function operator<<(QDebug, QEvent const*): error: undefined reference to 'QDebug::putByteArray(char const*, unsigned int, QDebug::Latin1Content)'
.obj/qevent.o:qevent.cpp:function operator<<(QDebug, QEvent const*): error: undefined reference to 'QDebug::putByteArray(char const*, unsigned int, QDebug::Latin1Content)'
.obj/qevent.o:qevent.cpp:function operator<<(QDebug, QEvent const*): error: undefined reference to 'QDebug::putByteArray(char const*, unsigned int, QDebug::Latin1Content)'
.obj/qkeysequence.o:qkeysequence.cpp:function QKeySequencePrivate::decodeString(QString const&, QKeySequence::SequenceFormat): error: undefined reference to 'QString::toLower_helper(QString const&)'
.obj/qkeysequence.o:qkeysequence.cpp:function QKeySequencePrivate::decodeString(QString const&, QKeySequence::SequenceFormat): error: undefined reference to 'QString::toLower_helper(QString const&)'
.obj/qscreen.o:qscreen.cpp:function operator<<(QDebug, QScreen const*): error: undefined reference to 'qt_QMetaEnum_debugOperator(QDebug&, int, QMetaObject const*, char const*)'
.obj/qhighdpiscaling.o:qhighdpiscaling.cpp:function QHighDpiScaling::initHighDpiScaling(): error: undefined reference to 'qEnvironmentVariableIntValue(char const*, bool*)'
.obj/qhighdpiscaling.o:qhighdpiscaling.cpp:function QHighDpiScaling::initHighDpiScaling(): error: undefined reference to 'QByteArray::toLower_helper(QByteArray&)'
.obj/qimage.o:qimage.cpp:function operator<<(QDebug, QImage const&): error: undefined reference to 'QDebug::resetFormat()'
.obj/qimage.o:qimage.cpp:function QImage::text(QString const&) const: error: undefined reference to 'QString::simplified_helper(QString const&)'
.obj/qimagereader.o:qimagereader.cpp:function createReadHandlerHelper(QIODevice*, QByteArray const&, bool, bool): error: undefined reference to 'QByteArray::toLower_helper(QByteArray const&)'
.obj/qimagereader.o:qimagereader.cpp:function QImageReaderPrivate::getText() [clone .part.30]: error: undefined reference to 'QString::simplified_helper(QString const&)'
.obj/qimagereader.o:qimagereader.cpp:function QImageReaderPrivate::getText() [clone .part.30]: error: undefined reference to 'QString::simplified_helper(QString&)'
.obj/qimagereader.o:qimagereader.cpp:function QImageReaderPrivate::initHandler(): error: undefined reference to 'QByteArray::toLower_helper(QByteArray const&)'
.obj/qimagewriter.o:qimagewriter.cpp:function QImageWriter::setText(QString const&, QString const&): error: undefined reference to 'QString::simplified_helper(QString const&)'
.obj/qimagewriter.o:qimagewriter.cpp:function QImageWriter::setText(QString const&, QString const&): error: undefined reference to 'QString::simplified_helper(QString const&)'
.obj/qpixmap.o:qpixmap.cpp:function operator<<(QDebug, QPixmap const&): error: undefined reference to 'QDebug::resetFormat()'
.obj/qicon.o:qicon.cpp:function operator<<(QDebug, QIcon const&): error: undefined reference to 'QDebug::resetFormat()'
.obj/qiconloader.o:qiconloader.cpp:function QIconLoader::findIconHelper(QString const&, QString const&, QStringList&) const: error: undefined reference to 'QString::trimmed_helper(QString const&)'
.obj/qppmhandler.o:qppmhandler.cpp:function QPpmHandler::setOption(QImageIOHandler::ImageOption, QVariant const&): error: undefined reference to 'QByteArray::toLower_helper(QByteArray&)'
.obj/qxbmhandler.o:qxbmhandler.cpp:function read_xbm_header(QIODevice*, int&, int&): error: undefined reference to 'QByteArray::trimmed_helper(QByteArray&)'
.obj/qxbmhandler.o:qxbmhandler.cpp:function read_xbm_header(QIODevice*, int&, int&): error: undefined reference to 'QByteArray::trimmed_helper(QByteArray&)'
.obj/qxpmhandler.o:qxpmhandler.cpp:function read_xpm_body(QIODevice*, char const* const*, int&, QByteArray&, int, int, int, int, QImage&): error: undefined reference to 'QByteArray::simplified_helper(QByteArray&)'
.obj/qxpmhandler.o:qxpmhandler.cpp:function read_xpm_body(QIODevice*, char const* const*, int&, QByteArray&, int, int, int, int, QImage&): error: undefined reference to 'QByteArray::trimmed_helper(QByteArray&)'
.obj/qxpmhandler.o:qxpmhandler.cpp:function read_xpm_body(QIODevice*, char const* const*, int&, QByteArray&, int, int, int, int, QImage&): error: undefined reference to 'QByteArray::toLower_helper(QByteArray&)'
.obj/qxpmhandler.o:qxpmhandler.cpp:function QXpmHandler::write(QImage const&): error: undefined reference to 'QString::asprintf(char const*, ...)'
.obj/qxpmhandler.o:qxpmhandler.cpp:function QXpmHandler::write(QImage const&): error: undefined reference to 'QString::asprintf(char const*, ...)'
.obj/qpnghandler.o:qpnghandler.cpp:function QPNGImageWriter::writeImage(QImage const&, int, QString const&, int, int): error: undefined reference to 'QString::simplified_helper(QString&)'
.obj/qfont.o:qfont.cpp:function QFont::substitute(QString const&): error: undefined reference to 'QString::toLower_helper(QString const&)'
.obj/qfontsubset.o:qfontsubset.cpp:function QFontSubset::toTruetype() const: error: undefined reference to 'QString::operator=(QLatin1String)'
.obj/qfontsubset.o:qfontsubset.cpp:function QFontSubset::toTruetype() const: error: undefined reference to 'QString::operator=(QLatin1String)'
.obj/qfontsubset.o:qfontsubset.cpp:function QFontSubset::toTruetype() const: error: undefined reference to 'QString::operator=(QLatin1String)'
.obj/qfontdatabase.o:qfontdatabase.cpp:function QFontDatabase::load(QFontPrivate const*, int): error: undefined reference to 'QString::trimmed_helper(QString const&)'
.obj/qtextdocument.o:qtextdocument.cpp:function findInBlock(QTextBlock const&, QRegularExpression const&, int, QFlags<QTextDocument::FindFlag>, QTextCursor*): error: undefined reference to 'QString::lastIndexOf(QRegularExpression const&, int, QRegularExpressionMatch*) const'
.obj/qtextdocument.o:qtextdocument.cpp:function findInBlock(QTextBlock const&, QRegularExpression const&, int, QFlags<QTextDocument::FindFlag>, QTextCursor*): error: undefined reference to 'QString::indexOf(QRegularExpression const&, int, QRegularExpressionMatch*) const'
.obj/qtexthtmlparser.o:qtexthtmlparser.cpp:function setWidthAttribute(QTextLength*, QString): error: undefined reference to 'QString::trimmed_helper(QString const&)'
.obj/qtexthtmlparser.o:qtexthtmlparser.cpp:function QTextHtmlParser::parseCloseTag(): error: undefined reference to 'QString::trimmed_helper(QString&)'
.obj/qcssparser.o:qcssparser.cpp:function parseColorValue(QCss::Value): error: undefined reference to 'QString::trimmed_helper(QString const&)'
.obj/qtextodfwriter.o:qtextodfwriter.cpp:function QTextOdfWriter::writeBlockFormat(QXmlStreamWriter&, QTextBlockFormat, int) const: error: undefined reference to 'qt_QMetaEnum_flagDebugOperator(QDebug&, unsigned long long, QMetaObject const*, char const*)'
.obj/qcolor.o:qcolor.cpp:function QColor::name(QColor::NameFormat) const: error: undefined reference to 'QString::asprintf(char const*, ...)'
.obj/qcolor.o:qcolor.cpp:function QColor::name(QColor::NameFormat) const: error: undefined reference to 'QString::asprintf(char const*, ...)'
.obj/qvalidator.o:qvalidator.cpp:function QDoubleValidator::validate(QString&, int&) const: error: undefined reference to 'QLocaleData::validateChars(QString const&, QLocaleData::NumberMode, QByteArray*, int, bool) const'
.obj/qvalidator.o:qvalidator.cpp:function QIntValidator::validate(QString&, int&) const: error: undefined reference to 'QLocaleData::validateChars(QString const&, QLocaleData::NumberMode, QByteArray*, int, bool) const'
.obj/qvalidator.o:qvalidator.cpp:function QIntValidator::fixup(QString&) const: error: undefined reference to 'QLocaleData::validateChars(QString const&, QLocaleData::NumberMode, QByteArray*, int, bool) const'
.obj/qvalidator.o:qvalidator.cpp:function QDoubleValidatorPrivate::validateWithLocale(QString&, QLocaleData::NumberMode, QLocale const&) const: error: undefined reference to 'QLocaleData::validateChars(QString const&, QLocaleData::NumberMode, QByteArray*, int, bool) const'
.obj/qopengl.o:qopengl.cpp:function (anonymous namespace)::VersionTerm::matches(QVersionNumber const&) const: error: undefined reference to 'QVersionNumber::compare(QVersionNumber const&, QVersionNumber const&)'
.obj/qopengl.o:qopengl.cpp:function (anonymous namespace)::VersionTerm::matches(QVersionNumber const&) const: error: undefined reference to 'QVersionNumber::compare(QVersionNumber const&, QVersionNumber const&)'
.obj/qopengl.o:qopengl.cpp:function (anonymous namespace)::VersionTerm::matches(QVersionNumber const&) const: error: undefined reference to 'QVersionNumber::compare(QVersionNumber const&, QVersionNumber const&)'
.obj/qopengl.o:qopengl.cpp:function (anonymous namespace)::VersionTerm::matches(QVersionNumber const&) const: error: undefined reference to 'QVersionNumber::compare(QVersionNumber const&, QVersionNumber const&)'
.obj/qopengl.o:qopengl.cpp:function (anonymous namespace)::VersionTerm::fromJson(QJsonValue const&): error: undefined reference to 'QVersionNumber::fromString(QString const&, int*)'
.obj/qopengl.o:qopengl.cpp:function operator<<(QDebug, QOpenGLConfig::Gpu const&): error: undefined reference to 'operator<<(QDebug, QVersionNumber const&)'
.obj/qopengl.o:qopengl.cpp:function QOpenGLConfig::gpuFeatures(QOpenGLConfig::Gpu const&, QJsonDocument const&): error: undefined reference to 'QSysInfo::kernelVersion()'
.obj/qopengl.o:qopengl.cpp:function QOpenGLConfig::gpuFeatures(QOpenGLConfig::Gpu const&, QJsonDocument const&): error: undefined reference to 'QVersionNumber::fromString(QString const&, int*)'
.obj/qopengl.o:qopengl.cpp:function QOpenGLConfig::gpuFeatures(QOpenGLConfig::Gpu const&, QString const&): error: undefined reference to 'QSysInfo::kernelVersion()'
.obj/qopengl.o:qopengl.cpp:function QOpenGLConfig::gpuFeatures(QOpenGLConfig::Gpu const&, QString const&): error: undefined reference to 'QVersionNumber::fromString(QString const&, int*)'
collect2: error: ld returned 1 exit status
Makefile:1205: recipe for target '../../lib/libQt5Gui.so.5.6.0' failed
make[2]: *** [../../lib/libQt5Gui.so.5.6.0] Error 1
make[2]: Leaving directory '/home/james/raspi/qtbase/src/gui'
Makefile:497: recipe for target 'sub-gui-make_first' failed
make[1]: *** [sub-gui-make_first] Error 2
make[1]: Leaving directory '/home/james/raspi/qtbase/src'
Makefile:45: recipe for target 'sub-src-make_first' failed
make: *** [sub-src-make_first] Error 2

我尝试在./configure期间添加-no-warnings-are-errors标志,以及从5.5(发行版)QT分支进行交叉编译。5.5分支在配置步骤中断。

有什么地方可以链接/指定源/添加标题吗?

似乎是我的raspbian图像上的qt5-default包导致了问题。改头换面或做sudo apt-get remove qt5-default解决了问题。

似乎是我的raspbian图像上的qt5默认包导致了问题

为了防止对其他人有帮助,删除PI上的qt5默认值并重新运行rsync命令是不够的。我不得不删除sysroot目录并重新运行rsync命令以使Qt编译。

我不知道这是否有必要,但我也从Pi中清除了所有qt5包。

仅仅删除qt5-default是不够的。

为了使构建成功,我不得不删除对预先安装的qt 5库的任何引用。

根据之前的交叉编译尝试,按照别人的配方,我安装了一个libqt5core5,它依赖于一堆额外的qt5库。

删除libqt5core5后,链接过程成功。当然,这也需要重新创建sysroot文件夹,因为Pi上的库已经更改。