[英]Unable to cross-compile Qt 5.14.2 for Raspberry PI zero w because it “requires a C++11 compiler”
This problem has already been encountered for previous versions of Qt5: Stack-overflow post (non-answered yet).以前版本的 Qt5 已经遇到过这个问题: Stack-overflow post (non-answered yet)。 I'm having the same problem with a more recent version and I have followed several tutorials online:
我在使用更新的版本时遇到了同样的问题,并且我在网上遵循了几个教程:
Even if all these tutorials are outdated, the methodology for cross compiling Qt5 stays the same.即使所有这些教程都已过时,交叉编译 Qt5 的方法保持不变。 My target board is a Raspberry pi zero w running Raspbian Buster.
我的目标板是运行 Raspbian Buster 的 Raspberry pi zero w。 The configuration steps have worked fine (there weren't any errors).
配置步骤运行良好(没有任何错误)。
I'm getting the following errors while executing make:执行 make 时出现以下错误:
~/Documents/Raspbian/raspi/qt-everywhere-src-5.14.2/qtbase/include/QtCore/../../src/corelib/thread/qbasicatomic.h:61:4: error: #error "Qt requires C++11 support"
# error "Qt requires C++11 support"
^
~/Documents/Raspbian/raspi/qt-everywhere-src-5.14.2/qtbase/include/QtCore/../../src/corelib/thread/qbasicatomic.h:94:13: error: ‘QAtomicOps’ does not name a type
typedef QAtomicOps<T> Ops;
^
In file included from ~/Documents/Raspbian/raspi/qt-everywhere-src-5.14.2/qtbase/include/QtCore/qglobal.h:1:0,
from ~/Documents/Raspbian/raspi/qt-everywhere-src-5.14.2/qtbase/src/corelib/global/qt_pch.h:56:
~/Documents/Raspbian/raspi/qt-everywhere-src-5.14.2/qtbase/include/QtCore/../../src/corelib/thread/qbasicatomic.h:97:23: error: ‘QAtomicOpsSupport’ was not declared in this scope
Q_STATIC_ASSERT_X(QAtomicOpsSupport<sizeof(T)>::IsSupported, "template parameter is an integral of a size not supported on this platform");
^
~/Documents/Raspbian/raspi/qt-everywhere-src-5.14.2/qtbase/include/QtCore/../../src/corelib/global/qglobal.h:121:68: note: in definition of macro ‘Q_STATIC_ASSERT_X’
# define Q_STATIC_ASSERT_X(Condition, Message) static_assert(bool(Condition), Message)
^
~/Documents/Raspbian/raspi/qt-everywhere-src-5.14.2/qtbase/include/QtCore/../../src/corelib/thread/qbasicatomic.h:97:51: error: ‘::IsSupported’ has not been declared
Q_STATIC_ASSERT_X(QAtomicOpsSupport<sizeof(T)>::IsSupported, "template parameter is an integral of a size not supported on this platform");
^
~/Documents/Raspbian/raspi/qt-everywhere-src-5.14.2/qtbase/include/QtCore/../../src/corelib/global/qglobal.h:121:68: note: in definition of macro ‘Q_STATIC_ASSERT_X’
# define Q_STATIC_ASSERT_X(Condition, Message) static_assert(bool(Condition), Message)
^
~/Documents/Raspbian/raspi/qt-everywhere-src-5.14.2/qtbase/include/QtCore/../../src/corelib/global/qglobal.h:121:49: error: non-constant condition for static assertion
# define Q_STATIC_ASSERT_X(Condition, Message) static_assert(bool(Condition), Message)
^
~/Documents/Raspbian/raspi/qt-everywhere-src-5.14.2/qtbase/include/QtCore/../../src/corelib/thread/qbasicatomic.h:97:5: note: in expansion of macro ‘Q_STATIC_ASSERT_X’
Q_STATIC_ASSERT_X(QAtomicOpsSupport<sizeof(T)>::IsSupported, "template parameter is an integral of a size not supported on this platform");
^
~/Documents/Raspbian/raspi/qt-everywhere-src-5.14.2/qtbase/include/QtCore/../../src/corelib/thread/qbasicatomic.h:97: confused by earlier errors, bailing out
make[3]: *** [Makefile:1836: .pch/Qt5Core.gch/c++] Error 1
make[3]: Leaving directory '~/Documents/Raspbian/raspi/qt5build/qtbase/src/corelib'
make[2]: *** [Makefile:228: sub-corelib-make_first] Error 2
make[2]: Leaving directory '~/Documents/Raspbian/raspi/qt5build/qtbase/src'
make[1]: *** [Makefile:51: sub-src-make_first] Error 2
make[1]: Leaving directory '~/Documents/Raspbian/raspi/qt5build/qtbase'
make: *** [Makefile:88: module-qtbase-make_first] Error 2
For future readers as pointed out the cross compiler provided by: https://github.com/raspberrypi/tools is outdated and cannot be used.对于未来的读者,正如所指出的, https://github.com/raspberrypi/tools提供的交叉编译器已过时,无法使用。 I have tried all the methods described above but the one that worked out-of-the-box (for Raspberry Pi 0 W which is based on older ARMv6 architecture) is: https://github.com/Pro/raspi-toolchain This repo provides a Docker image that compiles a newer toolchain from source and even provides a test code that you can cross compile using the generated toolchain and execute on the pi.
我已经尝试了上述所有方法,但开箱即用的方法(对于基于旧 ARMv6 架构的 Raspberry Pi 0 W)是: https://github.com/Pro/raspi-toolchain这个repo 提供了一个 Docker 映像,它从源代码编译更新的工具链,甚至提供了一个测试代码,您可以使用生成的工具链交叉编译并在 pi 上执行。
The compiler you're using is just too old.您使用的编译器太旧了。 The verison you're getting from the link you shared is 4.8.3, whereas you'll need at least gcc 5. (Check here: https://codereview.qt-project.org/c/qt/qtdoc/+/288825 )
您从共享的链接中获得的版本是 4.8.3,而您至少需要 gcc 5。(在此处查看: https://codereview.qt-project.org/c/qt/qtdoc/+/ 288825 )
The Error you get might be a bit misleading, since gcc itself states that it fully supports C++11 from 4.8.1 as stated here: https://gcc.gnu.org/projects/cxx-status.html#cxx11您得到的错误可能有点误导,因为 gcc 本身声明它完全支持 4.8.1 中的 C++11,如下所述: Z5E056C500A1C4B6A7110B50D8#07BADE/cxx-status.html#7BADE/cxx-status。
I propose u use a more up to date version of gcc.我建议你使用更新版本的 gcc。 As mentioned within the qt-docs, it should be at least gcc version 5 or higher.
如 qt-docs 中所述,它至少应为 gcc 版本 5 或更高版本。
There are several ways for you to et one (ordered from simple to more complicated):有几种方法供您选择(从简单到复杂排序):
Last but not least, don't forget to change the setting of your./configure step.最后但同样重要的是,不要忘记更改 ./configure 步骤的设置。 Pinpoint to the new toolchain you're trying to use.
精确定位到您尝试使用的新工具链。
Kind Regards亲切的问候
I had the same issue.我遇到过同样的问题。
I ended up with proper cross compilation of Qt 5.15.0 with EGL support only (to avoid using X11 on such tiny Rpi zero) with the following actions:我最终通过以下操作对仅支持 EGL 的 Qt 5.15.0 进行了正确的交叉编译(以避免在如此小的 Rpi 零上使用 X11):
1- As proposed by @glamis, I used the compilation toolchain from: https://github.com/Pro/raspi-toolchain via the pre-built toolchain in release v1.0.1 1- 正如@glamis 所提议的,我通过 v1.0.1 版本中的预构建工具链使用了来自: https://github.com/Pro/raspi-toolchain的编译工具链
2- (crappy) hacked in Qt sources qtdeclarative/src/3rdparty/masm/wtf/OSAllocatorPosix.cpp
: I replaced the constant PATH_MAX
(not present in this toolchain?) by hardcoded value 4096
2-(蹩脚)在 Qt 源代码
qtdeclarative/src/3rdparty/masm/wtf/OSAllocatorPosix.cpp
被黑:我用硬编码值4096
替换了常量PATH_MAX
(此工具链中不存在?)
3- still in Qt sources, edit the file qtbase/mkspecs/devices/linux-rasp-pi-g++/qmake.conf
3- 仍在 Qt 源中,编辑文件
qtbase/mkspecs/devices/linux-rasp-pi-g++/qmake.conf
3.a) replace all occurrences of -lEGL
-lGLESv2
-lOpenVG
by -lbrcmEGL
-lbrcmGLESv2
-lbrcmOpenVG
3.a) 将所有出现的
-lEGL
-lGLESv2
-lOpenVG
为-lbrcmEGL
-lbrcmGLESv2
-lbrcmOpenVG
3.b) move QMAKE_LIBS_OPENGL_ES2 = -lbrcmGLESv2 -lbrcmEGL
outside the if
statement to force it in all cases 3.b) 将
QMAKE_LIBS_OPENGL_ES2 = -lbrcmGLESv2 -lbrcmEGL
if
语句之外以在所有情况下强制它
notes:笔记:
raspberry pi zero, with "Raspberry Pi OS Lite" (aka. raspbian Lite) version, based on debian buster, version 2020-05-27树莓派零,带有“Raspberry Pi OS Lite”(又名 raspbian Lite)版本,基于 debian buster,版本 2020-05-27
dependencies installed: apt install build-essential libfontconfig1-dev libdbus-1-dev libfreetype6-dev libicu-dev libinput-dev libxkbcommon-dev libsqlite3-dev libssl-dev libpng-dev libjpeg-dev libglib2.0-dev libgbm-dev libraspberrypi-dev libudev-dev libinput-dev libts-dev libxcb-xinerama0-dev libxcb-xinerama0
安装的依赖项:
apt install build-essential libfontconfig1-dev libdbus-1-dev libfreetype6-dev libicu-dev libinput-dev libxkbcommon-dev libsqlite3-dev libssl-dev libpng-dev libjpeg-dev libglib2.0-dev libgbm-dev libraspberrypi-dev libudev-dev libinput-dev libts-dev libxcb-xinerama0-dev libxcb-xinerama0
qt archive used: qt-everywhere-src-5.15.0.tar.xz
使用的 qt 存档:
qt-everywhere-src-5.15.0.tar.xz
my configure looks like: configure -release -opensource -confirm-license -opengl es2 -device linux-rasp-pi-g++ -device-option CROSS_COMPILE=/opt/cross-pi-gcc/bin/arm-linux-gnueabihf- -sysroot $HOME/rpi/rootfs -prefix /usr/local/qt-5.15.0-rpi -extprefix $HOME/rpi/qt-5.15.0-rpi -hostprefix $HOME/rpi/tools -make libs -no-use-gold-linker -skip qtwayland -skip qtlocation -skip qtscript -v -no-gbm -ssl
我的配置看起来像:
configure -release -opensource -confirm-license -opengl es2 -device linux-rasp-pi-g++ -device-option CROSS_COMPILE=/opt/cross-pi-gcc/bin/arm-linux-gnueabihf- -sysroot $HOME/rpi/rootfs -prefix /usr/local/qt-5.15.0-rpi -extprefix $HOME/rpi/qt-5.15.0-rpi -hostprefix $HOME/rpi/tools -make libs -no-use-gold-linker -skip qtwayland -skip qtlocation -skip qtscript -v -no-gbm -ssl
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.