正点原子i.mux6ull开发板QT移植过程中遇到的问题,Ubuntu22.04环境,移植QT5.12.9时出现的问题;autoconfigure.sh脚本执行后报错,跟C++有关的错误。
为此,我在正点原子的论坛上提问了,但是没有人回答,提问内容如下:
按教程,移植qt5.12.9的时候,使用ubuntu16.04生成Makefile的时候一切正常,换成ubuntu22.04就失败,是g++版本抬高了的原因吗?用22.04配置内核编译环境的时候遇到过gcc版本过高的问题,不知道这里是不是同样的问题,有人遇到同样的问题吗?以下是我的操作步骤,只执行了./autoconfigure.sh ,然后查看了g++版本。 lvjun@lvjun-virtual-machine:~/study/i.mux6ull/qt/qt_src/qt-everywhere-src-5.12.9$ ./autoconfigure.sh + cd qtbase + /home/lvjun/study/i.mux6ull/qt/qt_src/qt-everywhere-src-5.12.9/qtbase/configure -top-level -prefix /home/lvjun/study/i.mux6ull/qt/qt_src/qt-everywhere-src-5.12.9/lvjun-arm-qt -opensource -confirm-license -release -strip -shared -xplatform linux-arm-gnueabi-g++ -optimized-qmake -c++std c++11 --rpath=no -pch -skip qt3d -skip qtactiveqt -skip qtandroidextras -skip qtcanvas3d -skip qtconnectivity -skip qtdatavis3d -skip qtdoc -skip qtgamepad -skip qtlocation -skip qtmacextras -skip qtnetworkauth -skip qtpurchasing -skip qtremoteobjects -skip qtscript -skip qtscxml -skip qtsensors -skip qtspeech -skip qtsvg -skip qttools -skip qttranslations -skip qtwayland -skip qtwebengine -skip qtwebview -skip qtwinextras -skip qtx11extras -skip qtxmlpatterns -make libs -make examples -nomake tools -nomake tests -gui -widgets -dbus-runtime --glib=no --iconv=no --pcre=qt --zlib=qt -no-openssl --freetype=qt --harfbuzz=qt -no-opengl -linuxfb --xcb=no -tslib --libpng=qt --libjpeg=qt --sqlite=qt -plugin-sql-sqlite -I/home/lvjun/study/i.mux6ull/qt/ts_lib/tslib-1.21/lvjun/include -L/home/lvjun/study/i.mux6ull/qt/ts_lib/tslib-1.21/lvjun/lib -recheck-all Creating qmake... ............................In file included from /home/lvjun/study/i.mux6ull/qt/qt_src/qt-everywhere-src-5.12.9/qtbase/include/QtCore/qendian.h:1, from /home/lvjun/study/i.mux6ull/qt/qt_src/qt-everywhere-src-5.12.9/qtbase/src/corelib/codecs/qutfcodec.cpp:43: /home/lvjun/study/i.mux6ull/qt/qt_src/qt-everywhere-src-5.12.9/qtbase/include/QtCore/../../src/corelib/global/qendian.h: In static member function ‘static constexpr QSpecialInteger<S> QSpecialInteger<S>::max()’: /home/lvjun/study/i.mux6ull/qt/qt_src/qt-everywhere-src-5.12.9/qtbase/include/QtCore/../../src/corelib/global/qendian.h:331:35: error: ‘numeric_limits’ is not a member of ‘std’ 331 | { return QSpecialInteger(std::numeric_limits<T>::max()); } | ^~~~~~~~~~~~~~ /home/lvjun/study/i.mux6ull/qt/qt_src/qt-everywhere-src-5.12.9/qtbase/include/QtCore/../../src/corelib/global/qendian.h:331:54: error: ‘::max’ has not been declared; did you mean ‘std::max’? 331 | { return QSpecialInteger(std::numeric_limits<T>::max()); } | ^~~ | std::max In file included from /usr/include/c++/11/algorithm:62, from /home/lvjun/study/i.mux6ull/qt/qt_src/qt-everywhere-src-5.12.9/qtbase/include/QtCore/../../src/corelib/global/qglobal.h:142, from /home/lvjun/study/i.mux6ull/qt/qt_src/qt-everywhere-src-5.12.9/qtbase/include/QtCore/qglobal.h:1, from /home/lvjun/study/i.mux6ull/qt/qt_src/qt-everywhere-src-5.12.9/qtbase/include/QtCore/../../src/corelib/tools/qchar.h:43, from /home/lvjun/study/i.mux6ull/qt/qt_src/qt-everywhere-src-5.12.9/qtbase/include/QtCore/qchar.h:1, from /home/lvjun/study/i.mux6ull/qt/qt_src/qt-everywhere-src-5.12.9/qtbase/include/QtCore/../../src/corelib/tools/qstring.h:48, from /home/lvjun/study/i.mux6ull/qt/qt_src/qt-everywhere-src-5.12.9/qtbase/include/QtCore/qstring.h:1, from /home/lvjun/study/i.mux6ull/qt/qt_src/qt-everywhere-src-5.12.9/qtbase/src/corelib/codecs/qutfcodec_p.h:55, from /home/lvjun/study/i.mux6ull/qt/qt_src/qt-everywhere-src-5.12.9/qtbase/src/corelib/codecs/qutfcodec.cpp:41: /usr/include/c++/11/bits/stl_algo.h:3467:5: note: ‘std::max’ declared here 3467 | max(initializer_list<_Tp> __l, _Compare __comp) | ^~~ In file included from /home/lvjun/study/i.mux6ull/qt/qt_src/qt-everywhere-src-5.12.9/qtbase/include/QtCore/qendian.h:1, from /home/lvjun/study/i.mux6ull/qt/qt_src/qt-everywhere-src-5.12.9/qtbase/src/corelib/codecs/qutfcodec.cpp:43: /home/lvjun/study/i.mux6ull/qt/qt_src/qt-everywhere-src-5.12.9/qtbase/include/QtCore/../../src/corelib/global/qendian.h:331:29: error: expected primary-expression before ‘(’ token 331 | { return QSpecialInteger(std::numeric_limits<T>::max()); } | ^ /home/lvjun/study/i.mux6ull/qt/qt_src/qt-everywhere-src-5.12.9/qtbase/include/QtCore/../../src/corelib/global/qendian.h:331:35: error: ‘numeric_limits’ is not a member of ‘std’ 331 | { return QSpecialInteger(std::numeric_limits<T>::max()); } | ^~~~~~~~~~~~~~ /home/lvjun/study/i.mux6ull/qt/qt_src/qt-everywhere-src-5.12.9/qtbase/include/QtCore/../../src/corelib/global/qendian.h:331:51: error: expected primary-expression before ‘>’ token 331 | { return QSpecialInteger(std::numeric_limits<T>::max()); } | ^ /home/lvjun/study/i.mux6ull/qt/qt_src/qt-everywhere-src-5.12.9/qtbase/include/QtCore/../../src/corelib/global/qendian.h:331:54: error: ‘::max’ has not been declared; did you mean ‘std::max’? 331 | { return QSpecialInteger(std::numeric_limits<T>::max()); } | ^~~ | std::max In file included from /usr/include/c++/11/algorithm:62, from /home/lvjun/study/i.mux6ull/qt/qt_src/qt-everywhere-src-5.12.9/qtbase/include/QtCore/../../src/corelib/global/qglobal.h:142, from /home/lvjun/study/i.mux6ull/qt/qt_src/qt-everywhere-src-5.12.9/qtbase/include/QtCore/qglobal.h:1, from /home/lvjun/study/i.mux6ull/qt/qt_src/qt-everywhere-src-5.12.9/qtbase/include/QtCore/../../src/corelib/tools/qchar.h:43, from /home/lvjun/study/i.mux6ull/qt/qt_src/qt-everywhere-src-5.12.9/qtbase/include/QtCore/qchar.h:1, from /home/lvjun/study/i.mux6ull/qt/qt_src/qt-everywhere-src-5.12.9/qtbase/include/QtCore/../../src/corelib/tools/qstring.h:48, from /home/lvjun/study/i.mux6ull/qt/qt_src/qt-everywhere-src-5.12.9/qtbase/include/QtCore/qstring.h:1, from /home/lvjun/study/i.mux6ull/qt/qt_src/qt-everywhere-src-5.12.9/qtbase/src/corelib/codecs/qutfcodec_p.h:55, from /home/lvjun/study/i.mux6ull/qt/qt_src/qt-everywhere-src-5.12.9/qtbase/src/corelib/codecs/qutfcodec.cpp:41: /usr/include/c++/11/bits/stl_algo.h:3467:5: note: ‘std::max’ declared here 3467 | max(initializer_list<_Tp> __l, _Compare __comp) | ^~~ In file included from /home/lvjun/study/i.mux6ull/qt/qt_src/qt-everywhere-src-5.12.9/qtbase/include/QtCore/qendian.h:1, from /home/lvjun/study/i.mux6ull/qt/qt_src/qt-everywhere-src-5.12.9/qtbase/src/corelib/codecs/qutfcodec.cpp:43: /home/lvjun/study/i.mux6ull/qt/qt_src/qt-everywhere-src-5.12.9/qtbase/include/QtCore/../../src/corelib/global/qendian.h: In static member function ‘static constexpr QSpecialInteger<S> QSpecialInteger<S>::min()’: /home/lvjun/study/i.mux6ull/qt/qt_src/qt-everywhere-src-5.12.9/qtbase/include/QtCore/../../src/corelib/global/qendian.h:333:35: error: ‘numeric_limits’ is not a member of ‘std’ 333 | { return QSpecialInteger(std::numeric_limits<T>::min()); } | ^~~~~~~~~~~~~~ /home/lvjun/study/i.mux6ull/qt/qt_src/qt-everywhere-src-5.12.9/qtbase/include/QtCore/../../src/corelib/global/qendian.h:333:54: error: ‘::min’ has not been declared; did you mean ‘std::min’? 333 | { return QSpecialInteger(std::numeric_limits<T>::min()); } | ^~~ | std::min In file included from /usr/include/c++/11/algorithm:62, from /home/lvjun/study/i.mux6ull/qt/qt_src/qt-everywhere-src-5.12.9/qtbase/include/QtCore/../../src/corelib/global/qglobal.h:142, from /home/lvjun/study/i.mux6ull/qt/qt_src/qt-everywhere-src-5.12.9/qtbase/include/QtCore/qglobal.h:1, from /home/lvjun/study/i.mux6ull/qt/qt_src/qt-everywhere-src-5.12.9/qtbase/include/QtCore/../../src/corelib/tools/qchar.h:43, from /home/lvjun/study/i.mux6ull/qt/qt_src/qt-everywhere-src-5.12.9/qtbase/include/QtCore/qchar.h:1, from /home/lvjun/study/i.mux6ull/qt/qt_src/qt-everywhere-src-5.12.9/qtbase/include/QtCore/../../src/corelib/tools/qstring.h:48, from /home/lvjun/study/i.mux6ull/qt/qt_src/qt-everywhere-src-5.12.9/qtbase/include/QtCore/qstring.h:1, from /home/lvjun/study/i.mux6ull/qt/qt_src/qt-everywhere-src-5.12.9/qtbase/src/corelib/codecs/qutfcodec_p.h:55, from /home/lvjun/study/i.mux6ull/qt/qt_src/qt-everywhere-src-5.12.9/qtbase/src/corelib/codecs/qutfcodec.cpp:41: /usr/include/c++/11/bits/stl_algo.h:3455:5: note: ‘std::min’ declared here 3455 | min(initializer_list<_Tp> __l, _Compare __comp) | ^~~ In file included from /home/lvjun/study/i.mux6ull/qt/qt_src/qt-everywhere-src-5.12.9/qtbase/include/QtCore/qendian.h:1, from /home/lvjun/study/i.mux6ull/qt/qt_src/qt-everywhere-src-5.12.9/qtbase/src/corelib/codecs/qutfcodec.cpp:43: /home/lvjun/study/i.mux6ull/qt/qt_src/qt-everywhere-src-5.12.9/qtbase/include/QtCore/../../src/corelib/global/qendian.h:333:29: error: expected primary-expression before ‘(’ token 333 | { return QSpecialInteger(std::numeric_limits<T>::min()); } | ^ /home/lvjun/study/i.mux6ull/qt/qt_src/qt-everywhere-src-5.12.9/qtbase/include/QtCore/../../src/corelib/global/qendian.h:333:35: error: ‘numeric_limits’ is not a member of ‘std’ 333 | { return QSpecialInteger(std::numeric_limits<T>::min()); } | ^~~~~~~~~~~~~~ /home/lvjun/study/i.mux6ull/qt/qt_src/qt-everywhere-src-5.12.9/qtbase/include/QtCore/../../src/corelib/global/qendian.h:333:51: error: expected primary-expression before ‘>’ token 333 | { return QSpecialInteger(std::numeric_limits<T>::min()); } | ^ /home/lvjun/study/i.mux6ull/qt/qt_src/qt-everywhere-src-5.12.9/qtbase/include/QtCore/../../src/corelib/global/qendian.h:333:54: error: ‘::min’ has not been declared; did you mean ‘std::min’? 333 | { return QSpecialInteger(std::numeric_limits<T>::min()); } | ^~~ | std::min In file included from /usr/include/c++/11/algorithm:62, from /home/lvjun/study/i.mux6ull/qt/qt_src/qt-everywhere-src-5.12.9/qtbase/include/QtCore/../../src/corelib/global/qglobal.h:142, from /home/lvjun/study/i.mux6ull/qt/qt_src/qt-everywhere-src-5.12.9/qtbase/include/QtCore/qglobal.h:1, from /home/lvjun/study/i.mux6ull/qt/qt_src/qt-everywhere-src-5.12.9/qtbase/include/QtCore/../../src/corelib/tools/qchar.h:43, from /home/lvjun/study/i.mux6ull/qt/qt_src/qt-everywhere-src-5.12.9/qtbase/include/QtCore/qchar.h:1, from /home/lvjun/study/i.mux6ull/qt/qt_src/qt-everywhere-src-5.12.9/qtbase/include/QtCore/../../src/corelib/tools/qstring.h:48, from /home/lvjun/study/i.mux6ull/qt/qt_src/qt-everywhere-src-5.12.9/qtbase/include/QtCore/qstring.h:1, from /home/lvjun/study/i.mux6ull/qt/qt_src/qt-everywhere-src-5.12.9/qtbase/src/corelib/codecs/qutfcodec_p.h:55, from /home/lvjun/study/i.mux6ull/qt/qt_src/qt-everywhere-src-5.12.9/qtbase/src/corelib/codecs/qutfcodec.cpp:41: /usr/include/c++/11/bits/stl_algo.h:3455:5: note: ‘std::min’ declared here 3455 | min(initializer_list<_Tp> __l, _Compare __comp) | ^~~ gmake: *** [Makefile:382:qutfcodec.o] 错误 1 lvjun@lvjun-virtual-machine:~/study/i.mux6ull/qt/qt_src/qt-everywhere-src-5.12.9$ g++ --version g++ (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0 Copyright (C) 2021 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. lvjun@lvjun-virtual-machine:~/study/i.mux6ull/qt/qt_src/qt-everywhere-src-5.12.9$
原因是22.04的ubuntu的默认g++版本过高,对比正点原子提供的虚拟机,发现教学用的虚拟机g++版本是5.4.0,所以,只要降级到这个版本,理论上就没有问题了。
下面开始操作:
编辑软件源文件
sudo vim /etc/apt/sources.list
在最后添加一行:这是一个ubuntu16.04的软件源地址里面有gcc和g++等软件
deb https://mirrors.aliyun.com/ubuntu/ xenial main universe
更新软件源
sudo apt-get update
注意,有时update时会报错, 提示GPG error缺少公钥,多见于添加了xenial版本(Ubuntu16)源 此时,解决办法根据报错信息“NO_PUBKEY 40976EAF437D05B5 NO_PUBKEY 3B4FE6ACC0B21F32”导入对应公钥即可
如果没遇到这个问题,就跳过这一步
sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 40976EAF437D05B5 sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 3B4FE6ACC0B21F32
更新完以后就可以安装g++5了,不用指定5.4.0,会自动安装5.4.0
sudo apt install g++-5
提升g++5的优先级
update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-5 50
现在再尝试执行autoconfigure.sh脚本生成Makefile,就没有问题了。