簡體   English   中英

無法為 Raspberry PI zero w 交叉編譯 Qt 5.14.2,因為它“需要 C++11 編譯器”

[英]Unable to cross-compile Qt 5.14.2 for Raspberry PI zero w because it “requires a C++11 compiler”

以前版本的 Qt5 已經遇到過這個問題: Stack-overflow post (non-answered yet)。 我在使用更新的版本時遇到了同樣的問題,並且我在網上遵循了幾個教程:

即使所有這些教程都已過時,交叉編譯 Qt5 的方法保持不變。 我的目標板是運行 Raspbian Buster 的 Raspberry pi zero w。 配置步驟運行良好(沒有任何錯誤)。

執行 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

對於未來的讀者,正如所指出的, https://github.com/raspberrypi/tools提供的交叉編譯器已過時,無法使用。 我已經嘗試了上述所有方法,但開箱即用的方法(對於基於舊 ARMv6 架構的 Raspberry Pi 0 W)是: https://github.com/Pro/raspi-toolchain這個repo 提供了一個 Docker 映像,它從源代碼編譯更新的工具鏈,甚至提供了一個測試代碼,您可以使用生成的工具鏈交叉編譯並在 pi 上執行。

您使用的編譯器太舊了。 您從共享的鏈接中獲得的版本是 4.8.3,而您至少需要 gcc 5。(在此處查看: https://codereview.qt-project.org/c/qt/qtdoc/+/ 288825 )

您得到的錯誤可能有點誤導,因為 gcc 本身聲明它完全支持 4.8.1 中的 C++11,如下所述: Z5E056C500A1C4B6A7110B50D8#07BADE/cxx-status.html#7BADE/cxx-status。

我建議你使用更新版本的 gcc。 如 qt-docs 中所述,它至少應為 gcc 版本 5 或更高版本。

有幾種方法供您選擇(從簡單到復雜排序):

  1. 嘗試使用系統的 package 管理器(例如 sudo apt install gcc-arm-linux-gnueabihf)
  2. 在別處下載一個。 (例如這里: https://toolchains.bootlin.com/
  3. 建立你自己的。 (也許使用 crosstool-ng)。 但請注意。 這可能很棘手,即使我在使用 crosstool-ng 方面有很好的經驗。 或類似的工具。

最后但同樣重要的是,不要忘記更改 ./configure 步驟的設置。 精確定位到您嘗試使用的新工具鏈。

親切的問候

我遇到過同樣的問題。

我最終通過以下操作對僅支持 EGL 的 Qt 5.15.0 進行了正確的交叉編譯(以避免在如此小的 Rpi 零上使用 X11):

1- 正如@glamis 所提議的,我通過 v1.0.1 版本中的預構建工具鏈使用了來自: https://github.com/Pro/raspi-toolchain的編譯工具鏈

2-(蹩腳)在 Qt 源代碼qtdeclarative/src/3rdparty/masm/wtf/OSAllocatorPosix.cpp被黑:我用硬編碼值4096替換了常量PATH_MAX (此工具鏈中不存在?)

3- 仍在 Qt 源中,編輯文件qtbase/mkspecs/devices/linux-rasp-pi-g++/qmake.conf

3.a) 將所有出現的-lEGL -lGLESv2 -lOpenVG-lbrcmEGL -lbrcmGLESv2 -lbrcmOpenVG

3.b) 將QMAKE_LIBS_OPENGL_ES2 = -lbrcmGLESv2 -lbrcmEGL if語句之外以在所有情況下強制它

筆記:

  • 樹莓派零,帶有“Raspberry Pi OS Lite”(又名 raspbian Lite)版本,基於 debian buster,版本 2020-05-27

  • 安裝的依賴項: 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 存檔: qt-everywhere-src-5.15.0.tar.xz

  • 我的配置看起來像: 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.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM