IMX6ULL + QT5.12.9 移植问题及解决方法

一.开发环境

  1. Ubuntu-22.04.3
  2. 正点原子阿尔法开发版IMX6ULL
  3. QT5.12.9

二.QT源码编译及出现问题解决

  1. 下载QT源码并发送到Ubuntu或者直接通过wget下载:
    wget https://download.qt.io/archive/qt/5.12/5.12.9/single/qt-everywhere-src-5.12.9.tar.xz在这里插入图片描述
  2. 解压: tar xf qt-everywhere-src-5.12.9.tar.xz
  3. 进入目录 cd qt-everywhere-src-5.12.9/
  4. 编辑 qmake.conf vi qtbase/mkspecs/linux-arm-gnueabi-g++/qmake.conf
#
# qmake configuration for building with arm-linux-gnueabi-g++
#

MAKEFILE_GENERATOR = UNIX
CONFIG += incremental
QMAKE_INCREMENTAL_STYLE = sublib

QT_QPA_DEFAULT_PLATFORM = linuxfb
QMAKE_CFLAGS += -O2 -march=armv7-a -mtune=cortex-a7 -mfpu=neon -mfloat-abi=hard
QMAKE_CXXFLAGS += -O2 -march=armv7-a -mtune=cortex-a7 -mfpu=neon -mfloat-abi=hard

include(../common/linux.conf)
include(../common/gcc-base-unix.conf)
include(../common/g++-unix.conf)

# modifications to g++.conf
QMAKE_CC = arm-linux-gnueabihf-gcc
QMAKE_CXX = arm-linux-gnueabihf-g++
QMAKE_LINK = arm-linux-gnueabihf-g++
QMAKE_LINK_SHLIB = arm-linux-gnueabihf-g++

# modifications to linux.conf
QMAKE_AR = arm-linux-gnueabihf-ar cqs
QMAKE_OBJCOPY = arm-linux-gnueabihf-objcopy
QMAKE_NM = arm-linux-gnueabihf-nm -P
QMAKE_STRIP = arm-linux-gnueabihf-strip
load(qt_config)
  1. 创建autoconfigure.sh vi autoconfigure.sh,加入以下内容,如果用的是正点原子的配置,最好另外加上-skip qtdeclarative \,不然安装的时候会报错。
./configure -prefix /home/liwanfang/linux/tool/qt-everywhere-src-5.12.9/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 \
-skip qtdeclarative \
-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/liwanfang/linux/tool/tslib-1.21/arm-tslib/include \
-L/home/liwanfang/linux/tool/tslib-1.21/arm-tslib/lib \
-recheck-all

注意:第一行和倒数二,三行路径需要根据自己的环境修改
6. 修改脚本可执行权限 chmod +x autoconfigure.sh
7. 安装g++ sudo apt-get install g++
8. 执行脚本 ./autoconfigure.sh
9. 我在这里遇到了错误

Creating qmake...
............................In file included from /home/liwanfang/linux/tool/qt-everywhere-src-5.12.9/qtbase/include/QtCore/qendian.h:1,
                 from /home/liwanfang/linux/tool/qt-everywhere-src-5.12.9/qtbase/src/corelib/codecs/qutfcodec.cpp:43:
/home/liwanfang/linux/tool/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/liwanfang/linux/tool/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/liwanfang/linux/tool/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/liwanfang/linux/tool/qt-everywhere-src-5.12.9/qtbase/include/QtCore/../../src/corelib/global/qglobal.h:142,
                 from /home/liwanfang/linux/tool/qt-everywhere-src-5.12.9/qtbase/include/QtCore/qglobal.h:1,
                 from /home/liwanfang/linux/tool/qt-everywhere-src-5.12.9/qtbase/include/QtCore/../../src/corelib/tools/qchar.h:43,
                 from /home/liwanfang/linux/tool/qt-everywhere-src-5.12.9/qtbase/include/QtCore/qchar.h:1,
                 from /home/liwanfang/linux/tool/qt-everywhere-src-5.12.9/qtbase/include/QtCore/../../src/corelib/tools/qstring.h:48,
                 from /home/liwanfang/linux/tool/qt-everywhere-src-5.12.9/qtbase/include/QtCore/qstring.h:1,
                 from /home/liwanfang/linux/tool/qt-everywhere-src-5.12.9/qtbase/src/corelib/codecs/qutfcodec_p.h:55,
                 from /home/liwanfang/linux/tool/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/liwanfang/linux/tool/qt-everywhere-src-5.12.9/qtbase/include/QtCore/qendian.h:1,
                 from /home/liwanfang/linux/tool/qt-everywhere-src-5.12.9/qtbase/src/corelib/codecs/qutfcodec.cpp:43:
/home/liwanfang/linux/tool/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/liwanfang/linux/tool/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/liwanfang/linux/tool/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/liwanfang/linux/tool/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/liwanfang/linux/tool/qt-everywhere-src-5.12.9/qtbase/include/QtCore/../../src/corelib/global/qglobal.h:142,
                 from /home/liwanfang/linux/tool/qt-everywhere-src-5.12.9/qtbase/include/QtCore/qglobal.h:1,
                 from /home/liwanfang/linux/tool/qt-everywhere-src-5.12.9/qtbase/include/QtCore/../../src/corelib/tools/qchar.h:43,
                 from /home/liwanfang/linux/tool/qt-everywhere-src-5.12.9/qtbase/include/QtCore/qchar.h:1,
                 from /home/liwanfang/linux/tool/qt-everywhere-src-5.12.9/qtbase/include/QtCore/../../src/corelib/tools/qstring.h:48,
                 from /home/liwanfang/linux/tool/qt-everywhere-src-5.12.9/qtbase/include/QtCore/qstring.h:1,
                 from /home/liwanfang/linux/tool/qt-everywhere-src-5.12.9/qtbase/src/corelib/codecs/qutfcodec_p.h:55,
                 from /home/liwanfang/linux/tool/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/liwanfang/linux/tool/qt-everywhere-src-5.12.9/qtbase/include/QtCore/qendian.h:1,
                 from /home/liwanfang/linux/tool/qt-everywhere-src-5.12.9/qtbase/src/corelib/codecs/qutfcodec.cpp:43:
/home/liwanfang/linux/tool/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/liwanfang/linux/tool/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/liwanfang/linux/tool/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/liwanfang/linux/tool/qt-everywhere-src-5.12.9/qtbase/include/QtCore/../../src/corelib/global/qglobal.h:142,
                 from /home/liwanfang/linux/tool/qt-everywhere-src-5.12.9/qtbase/include/QtCore/qglobal.h:1,
                 from /home/liwanfang/linux/tool/qt-everywhere-src-5.12.9/qtbase/include/QtCore/../../src/corelib/tools/qchar.h:43,
                 from /home/liwanfang/linux/tool/qt-everywhere-src-5.12.9/qtbase/include/QtCore/qchar.h:1,
                 from /home/liwanfang/linux/tool/qt-everywhere-src-5.12.9/qtbase/include/QtCore/../../src/corelib/tools/qstring.h:48,
                 from /home/liwanfang/linux/tool/qt-everywhere-src-5.12.9/qtbase/include/QtCore/qstring.h:1,
                 from /home/liwanfang/linux/tool/qt-everywhere-src-5.12.9/qtbase/src/corelib/codecs/qutfcodec_p.h:55,
                 from /home/liwanfang/linux/tool/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/liwanfang/linux/tool/qt-everywhere-src-5.12.9/qtbase/include/QtCore/qendian.h:1,
                 from /home/liwanfang/linux/tool/qt-everywhere-src-5.12.9/qtbase/src/corelib/codecs/qutfcodec.cpp:43:
/home/liwanfang/linux/tool/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/liwanfang/linux/tool/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/liwanfang/linux/tool/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/liwanfang/linux/tool/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/liwanfang/linux/tool/qt-everywhere-src-5.12.9/qtbase/include/QtCore/../../src/corelib/global/qglobal.h:142,
                 from /home/liwanfang/linux/tool/qt-everywhere-src-5.12.9/qtbase/include/QtCore/qglobal.h:1,
                 from /home/liwanfang/linux/tool/qt-everywhere-src-5.12.9/qtbase/include/QtCore/../../src/corelib/tools/qchar.h:43,
                 from /home/liwanfang/linux/tool/qt-everywhere-src-5.12.9/qtbase/include/QtCore/qchar.h:1,
                 from /home/liwanfang/linux/tool/qt-everywhere-src-5.12.9/qtbase/include/QtCore/../../src/corelib/tools/qstring.h:48,
                 from /home/liwanfang/linux/tool/qt-everywhere-src-5.12.9/qtbase/include/QtCore/qstring.h:1,
                 from /home/liwanfang/linux/tool/qt-everywhere-src-5.12.9/qtbase/src/corelib/codecs/qutfcodec_p.h:55,
                 from /home/liwanfang/linux/tool/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
./autoconfigure.sh:60: -I/home/liwanfang/linux/tool/tslib-1.21/arm-tslib/include: 没有那个文件或目录

解决方案:
百度搜了说在报错的文件里将#include <limits>包含进去

#include <limits>

修改解决完所有报错后重新执行./autoconfigure.sh脚本就可以成功啦
配置成功
10. 执行make编译 time (make -j16) ====> -j16 代表最多允许 16 条编译指令同时运行,参数 16,一般为个人分配给虚拟机的核心数的 2 倍,前面加个 time 是测试编译时间。
11. 编译过程中出现报错:

walker.o treewalker.cpp
make[3]: *** [Makefile:787:.obj/generator.o] 错误 1
make[3]: *** 正在等待未完成的任务....
../moc/generator.cpp: In function ‘CborError jsonValueToCbor(CborEncoder*, const QJsonValue&)’:
../moc/generator.cpp:1612:63: error: ‘numeric_limits’ is not a member of ‘std’
1612 |         if (d == floor(d) && fabs(d) <= (Q_INT64_C(1) << std::numeric_limits<double>::digits))
    |                                                               ^~~~~~~~~~~~~~
../moc/generator.cpp:1612:78: error: expected primary-expression before ‘double’
1612 |         if (d == floor(d) && fabs(d) <= (Q_INT64_C(1) << std::numeric_limits<double>::digits))
    |                                                                              ^~~~~~
../moc/generator.cpp:1612:78: error: expected ‘)’ before ‘double’
1612 |         if (d == floor(d) && fabs(d) <= (Q_INT64_C(1) << std::numeric_limits<double>::digits))
    |                                         ~                                    ^~~~~~
    |                                                                              )
../moc/generator.cpp:1613:54: error: expected ‘)’ before ‘;’ token
1613 |             return cbor_encode_int(parent, qint64(d));


//编译最后报错....很无语 
make[3]: *** [Makefile:812:.obj/generator.o] 错误 1
make[3]: *** 正在等待未完成的任务....
g++ -Wl,-O1 -Wl,--gc-sections -o ../../../bin/qdbusxml2cpp .obj/qdbusxml2cpp.o   /home/liwanfang/linux/tool/qt-everywhere-src-5.12.9/qtbase/lib/libQt5BootstrapDBus.a /home/liwanfang/linux/tool/qt-everywhere-src-5.12.9/qtbase/lib/libQt5Bootstrap.a -lpthread   
make[3]: 离开目录“/home/liwanfang/linux/tool/qt-everywhere-src-5.12.9/qtbase/src/tools/qdbusxml2cpp”
make[3]: 离开目录“/home/liwanfang/linux/tool/qt-everywhere-src-5.12.9/qtbase/src/tools/qdbuscpp2xml”
make[2]: *** [Makefile:455:sub-qdbuscpp2xml-make_first] 错误 2
make[2]: 离开目录“/home/liwanfang/linux/tool/qt-everywhere-src-5.12.9/qtbase/src”
make[1]: *** [Makefile:51:sub-src-make_first] 错误 2
make[1]: 离开目录“/home/liwanfang/linux/tool/qt-everywhere-src-5.12.9/qtbase”
make: *** [Makefile:59:module-qtbase-make_first] 错误 2

  1. 解决方案:同上第9点在报错源文件中包含头文件 limits.h,通过命令find ./ -name "generator.cpp"找到报错文件路径,在文件中插入以下代码vim ./qtbase/src/tools/moc/generator.cpp
#include <limits>

在这里插入图片描述
在这里插入图片描述
修改完成后重新执行time(make -j16)就可以编译成功啦
在这里插入图片描述
12. 编译成功后执行make install安装,如果在第5步没有添加-skip qtdeclarative配置项,在这里有可能会出现下面错误,困难重重啊,不过不要急,一定可以解决的!!!

clarative/qtdeclarative.pro ) && make -f Makefile install
sh: 1: python: not found
Project ERROR: Building QtQml requires Python.
make: *** [Makefile:171:module-qtdeclarative-install_subtargets] 错误 3

解决方法:
(1)在make install后面加上-skip qtdeclarative,即make install -skip qtdeclarative这种方法我试了会很慢,建议用第(2)种方法.
(2)回到第5步,在autoconfigure.sh 中加上-skip qtdeclarative \重新配置编译一次.
在这里插入图片描述
重新配置编译后可以安装成功啦

/home/liwanfang/linux/tool/qt-everywhere-src-5.12.9/qtbase/bin/qmake -install qinstall /home/liwanfang/linux/tool/qt-everywhere-src-5.12.9/qtcharts/examples/charts/charts.pro /home/liwanfang/linux/tool/qt-everywhere-src-5.12.9/arm-qt/examples/charts/charts.pro
make[3]: 离开目录“/home/liwanfang/linux/tool/qt-everywhere-src-5.12.9/qtcharts/examples/charts”
make[2]: 离开目录“/home/liwanfang/linux/tool/qt-everywhere-src-5.12.9/qtcharts/examples”
make[1]: 离开目录“/home/liwanfang/linux/tool/qt-everywhere-src-5.12.9/qtcharts”

在这里插入图片描述

三.QT 移植到文件系统

1. 移植 tslib 到文件系统
  1. 打包arm-tslib tar -jcf ./arm-tslib.tar.bz2 arm-tslib
  2. 在开发版任意目录新建tools目录,将arm-tslib.tar.bz2拷贝到开发版文件系统tools目录下,直接拷贝,scp传输,U盘传输都可以.
  3. 在开发版执行解压命令 tar xf arm-tslib.tar.bz2 -C /usr/lib解压
  4. 添加配置/etc/profile,vi /etc/profile
export TSLIB_ROOT=/usr/lib/arm-tslib
export TSLIB_CONSOLEDEVICE=none
export TSLIB_FBDEVICE=/dev/fb0
export TSLIB_TSDEVICE=/dev/input/event1
export TSLIB_CONFFILE=$TSLIB_ROOT/etc/ts.conf
export TSLIB_PLUGINDIR=$TSLIB_ROOT/lib/ts
export TSLIB_CALIBFILE=/etc/pointercal
export LD_PRELOAD=$TSLIB_ROOT/lib/libts.so
  1. 使能环境变量source /etc/profile ,测试/usr/lib/arm-tslib/bin/ts_test
2. 移植 Qt 到文件系统
  1. 将 arm-qt打包tar -jcf ./arm-qt.tar.bz2 arm-qt
  2. 将arm-qt.tar.bz2拷贝到开发版文件系统tools目录下
  3. 在开发版解压arm-qt.tar.bz2 tar xf arm-qt.tar.bz2 -C /usr/lib
  4. 配置 Qt5 的环境变量,编辑/etc/profile,其中/usr/share/fonts为字体存放目录,如果要支持中文,将字体复制到此目录.
export QT_ROOT=/usr/lib/arm-qt
export QT_QPA_GENERIC_PLUGINS=tslib:/dev/input/event1
export QT_QPA_FONTDIR=/usr/share/fonts
export QT_QPA_PLATFORM_PLUGIN_PATH=$QT_ROOT/plugins
export QT_QPA_PLATFORM=linuxfb:tty=/dev/fb0
export QT_PLUGIN_PATH=$QT_ROOT/plugins
export LD_LIBRARY_PATH=$QT_ROOT/lib:$QT_ROOT/plugins/platforms
export QML2_IMPORT_PATH=$QT_ROOT/qml
export QT_QPA_FB_TSLIB=1
  1. 使能环境变量 source /etc/profile
  2. 测试运行 /usr/lib/arm-qt/examples/widgets/animation/animatedtiles/animatedtiles
    在这里插入图片描述

到这里大功告成,自己编写的QT程序通过交叉编译器编译也可以直接在开发版运行啦…

  • 26
    点赞
  • 15
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

博创客

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值