前言:

项目需要移植qt到arm开发板上,历经千辛万苦解决了各种问题,最后终于成功了,所以整理了开发笔记给更多的小伙伴参考。

1.准备阶段

①下载交叉编译器aarch65-linux-gnu,下载地址为:Linaro Releases

②下载Qt5.9.6源码,下载地址为:Index of /archive/qt/5.9/5.9.6/single

③下载Qtcreator安装包,下载地址为:Index of /archive/qt/5.9/5.9.6

④安装虚拟机VMware® Workstation 14 Pro和Ubuntu16.04.5 LTS,博主的虚拟机版本如下图:

⑤将文件分别存放在相应文件夹下并解压:

****.tar.gz 文件的解压命令是 :tar -zxvf ****.tar.gz

****.tar.xz 文件的解压命令是 :tar xvJf ****.tar.xz

第一步的准备工作已完成。


2. 安装交叉编译器:

交叉编译器解压之后的路径为:/home/admin/Qt_Env/Cross-compiler/

①查看当前环境变量命令:echo $PATH

②在/etc/profile中添加新的环境变量:

  • 执行命令:gedit /etc/profile

  • 在文件末尾添加:export PATH=$PATH:/home/admin/Qt_Env/Cross-compiler/aarch64-linux-gnu/bin

  • 执行命令:source /etc/profile

③再次执行echo $PATH

可以看到环境变量已经添加上了。

④验证编译器是否安装成功

  • 执行命令:aarch64-linux-gnu-g++ -v

终端显示编译器信息如下:

编译器安装成功。

注意:在/etc/profile中改变的环境变量是临时的,重启虚拟机或重启终端会导致环境变量修改不生效,所以在编译qt之前一定要确定交叉编译器安装成功,如果执行④打印的是gcc的版本信息,那么可能是编译器路径不对,或者多执行几次source /etc/profile即可。


3.交叉编译qt5.9.6

①配置qt的configure

在目录/home/Qt_Env/Qt_opensource下创建 qt_compiler_conf.sh文件,文件是configure的配置项,关于配置项的说明资料很多,在此不在赘述。

#!/bin/sh
./configure -prefix /opt/aarch64/qt596_64/qt_sdk \
-opensource \
-debug \
-confirm-license \
-xplatform linux-arm-gnueabi-g++ \
-no-opengl \
-no-pch \
-shared \
-no-iconv \
-no-xcb \

精简版configure:(两个.sh都可以)

#!/bin/bash./configure \-prefix ../arm-qt-output \-xplatform linux-aarch64-gnu-g++ \-no-static \-qt-libpng \-qt-libjpeg \-qt-zlib \-no-strip \-no-framework \-no-sse2 \-no-sse3 \-no-sse4.1 \-no-sse4.2 \-no-avx \-no-avx2 \-no-avx512 \-no-mips_dsp \-no-mips_dspr2 \-no-icu \-no-sql-sqlite \-no-accessibility \-no-ssl \-disable-system-proxies \-no-cups \-no-gtk \-no-opengles3 \-no-xcb \-no-ico \-no-opengl \-no-eglfs \-no-direct2d \-no-directfb \-no-gbm \-no-kms \-no-mirclient \-no-xcb \-no-xkbcommon-evdev \-no-xkbcommon-x11 \-no-doubleconversion \-enable-linuxfb \-qt-freetype \-make libs \-nomake examples \-nomake tests \-nomake tools \-opensource \-confirm-license \-skip qt3d \-skip qtactiveqt \-skip qtandroidextras \-skip qtcanvas3d \-skip qtcharts \-skip qtconnectivity \-skip qtdatavis3d \-skip qtdeclarative \-skip qtdoc \-skip qtgamepad \-skip qtgraphicaleffects \-skip qtlocation \-skip qtmacextras \-skip qtmultimedia \-skip qtnetworkauth \-skip qtpurchasing \-skip qtquickcontrols \-skip qtquickcontrols2 \-skip qtremoteobjects \-skip qtscript \-skip qtscxml \-skip qtsensors \-skip qtserialbus \-skip qtserialport \-skip qtspeech \-skip qtsvg \-skip qttools \-skip qttranslations \-skip qtvirtualkeyboard \-skip qtwayland \-skip qtwebchannel \-skip qtwebengine \-skip qtwebglplugin \-skip qtwebsockets \-skip qtwebview \-skip qtwinextras \-skip qtxmlpatterns \-skip qtx11extras \-no-iconv \-no-harfbuzz \-no-evdev

②修改qmake文件

安装目录打开:/home/hytera/Qt_Env/Qt_opensource/qt-everywhere-opensource-src-5.9.6/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 = sublibinclude(../common/linux.conf)
include(../common/gcc-base-unix.conf)
include(../common/g++-unix.conf)QT_QPA_DEFAULT_PLATFORM=linuxfb
# modifications to g++.conf
QMAKE_CC                = aarch64-linux-gnu-gcc
QMAKE_CXX               = aarch64-linux-gnu-g++
QMAKE_LINK              = aarch64-linux-gnu-g++
QMAKE_LINK_SHLIB        = aarch64-linux-gnu-g++# modifications to linux.conf
QMAKE_AR                = aarch64-linux-gnu-ar cqs
QMAKE_OBJCOPY           = aarch64-linux-gnu-objcopy
QMAKE_NM                = aarch64-linux-gnu-nm -P
QMAKE_STRIP             = aarch64-linux-gnu-strip
load(qt_config)

注意:arm开发板上显示屏的驱动是基于fb的话,记得在文件中添加QT_QPA_DEFAULT_PLATFORM=linuxfb。

③执行qt_compiler_conf.sh配置文件

※ 在终端执行命令:./qt_compiler_conf.sh

※ 或者,博主将终端打印的日志重定向到了confLog.txt文件中,方便查看,故执行的命令是:./qt_compiler_conf.sh  2>&1 | tee confLog.txt

※ 执行结果为:

+ cd qtbase
+ /home/hytera/Qt_Env/Qt_opensource/qt-everywhere-opensource-src-5.9.6/qtbase/configure -top-level -prefix /opt/aarch64/qt596_64/qt_sdk -opensource -debug -confirm-license -xplatform linux-arm-gnueabi-g++ -no-opengl -no-pch -shared -no-iconv -xcb
Creating qmake...
Done.This is the Qt Open Source Edition.You have already accepted the terms of the Open Source license.Running configuration tests...
Done running configuration tests.Configure summary:Building on: linux-g++ (x86_64, CPU features: mmx sse sse2)
Building for: linux-arm-gnueabi-g++ (arm64, CPU features: neon)
Configuration: cross_compile compile_examples enable_new_dtags largefile neon optimize_debug shared rpath debug c++11 c++14 c++1z concurrent dbus no-pkg-config reduce_exports release_tools stl
Build options:Mode ................................... debug; optimized toolsOptimize debug build ................... yesBuilding shared libraries .............. yesUsing C++ standard ..................... C++1zUsing ccache ........................... noUsing gold linker ...................... noUsing new DTAGS ........................ yesUsing precompiled headers .............. noUsing LTCG ............................. noTarget compiler supports:NEON ................................. yesBuild parts ............................ libs examples
Qt modules and options:Qt Concurrent .......................... yesQt D-Bus ............................... yesQt D-Bus directly linked to libdbus .... noQt Gui ................................. yesQt Network ............................. yesQt Sql ................................. yesQt Testlib ............................. yesQt Widgets ............................. yesQt Xml ................................. yes
Support enabled for:Using pkg-config ....................... noQML debugging .......................... yesudev ................................... noUsing system zlib ...................... no
Qt Core:DoubleConversion ....................... yesUsing system DoubleConversion ........ noGLib ................................... noiconv .................................. noICU .................................... noLogging backends:journald ............................. nosyslog ............................... noslog2 ................................ noUsing system PCRE2 ..................... no
Qt Network:getaddrinfo() .......................... yesgetifaddrs() ........................... yesIPv6 ifname ............................ yeslibproxy ............................... noOpenSSL ................................ noQt directly linked to OpenSSL ........ noSCTP ................................... noUse system proxies ..................... yes
Qt Gui:Accessibility .......................... yesFreeType ............................... yesUsing system FreeType ................ noHarfBuzz ............................... yesUsing system HarfBuzz ................ noFontconfig ............................. noImage formats:GIF .................................. yesICO .................................. yesJPEG ................................. yesUsing system libjpeg ............... noPNG .................................. yesUsing system libpng ................ noEGL .................................... noOpenVG ................................. noOpenGL:Desktop OpenGL ....................... noOpenGL ES 2.0 ........................ noOpenGL ES 3.0 ........................ noOpenGL ES 3.1 ........................ noSession Management ..................... yes
Features used by QPA backends:evdev .................................. yeslibinput ............................... noINTEGRITY HID .......................... nomtdev .................................. notslib .................................. noxkbcommon-evdev ........................ no
QPA backends:DirectFB ............................... noEGLFS .................................. noLinuxFB ................................ yesVNC .................................... yesMir client ............................. no
Qt Widgets:GTK+ ................................... noStyles ................................. Fusion Windows
Qt PrintSupport:CUPS ................................... no
Qt Sql:DB2 (IBM) .............................. noInterBase .............................. noMySql .................................. noOCI (Oracle) ........................... noODBC ................................... noPostgreSQL ............................. noSQLite2 ................................ noSQLite ................................. yesUsing system provided SQLite ......... noTDS (Sybase) ........................... no
Qt SerialBus:Socket CAN ............................. yesSocket CAN FD .......................... yes
QtXmlPatterns:XML schema support ..................... yes
Qt QML:QML interpreter ........................ yesQML network support .................... yes
Qt Quick:Direct3D 12 ............................ noAnimatedImage item ..................... yesCanvas item ............................ yesSupport for Qt Quick Designer .......... yesFlipable item .......................... yesGridView item .......................... yesListView item .......................... yesPath support ........................... yesPathView item .......................... yesPositioner items ....................... yesShaderEffect item ...................... yesSprite item ............................ yes
Qt Gamepad:SDL2 ................................... no
Qt 3D:Assimp ................................. yesSystem Assimp .......................... noOutput Qt3D Job traces ................. noOutput Qt3D GL traces .................. no
Qt 3D GeometryLoaders:Autodesk FBX ........................... no
Qt Wayland Client ........................ no
Qt Wayland Compositor .................... no
Qt Bluetooth:BlueZ .................................. noBlueZ Low Energy ....................... noLinux Crypto API ....................... no
Qt Sensors:sensorfw ............................... no
Qt Quick Controls 2:Styles ................................. Default Material Universal
Qt Quick Templates 2:Hover support .......................... yesMulti-touch support .................... yes
Qt Positioning:Gypsy GPS Daemon ....................... noWinRT Geolocation API .................. no
Qt Location:Geoservice plugins:OpenStreetMap ........................ yesHERE ................................. yesEsri ................................. yesMapbox ............................... yesMapboxGL ............................. noItemsoverlay ......................... yes
Qt Multimedia:ALSA ................................... noGStreamer 1.0 .......................... noGStreamer 0.10 ......................... noVideo for Linux ........................ yesOpenAL ................................. noPulseAudio ............................. noResource Policy (libresourceqt5) ....... noWindows Audio Services ................. noDirectShow ............................. noWindows Media Foundation ............... no
Qt WebEngine:Embedded build ......................... yesPepper Plugins ......................... noPrinting and PDF ....................... noProprietary Codecs ..................... noSpellchecker ........................... yesWebRTC ................................. noUsing system ninja ..................... noALSA ................................... noPulseAudio ............................. noSystem libraries:re2 .................................. noICU .................................. nolibwebp and libwebpdemux ............. noOpus ................................. noffmpeg ............................... noNote: Also available for Linux: linux-clang linux-iccNote: No wayland-egl support detected. Cross-toolkit compatibility disabled.Qt is now configured for building. Just run 'make'.
Once everything is built, you must run 'make install'.
Qt will be installed into '/opt/aarch64/qt596_64/qt_sdk'.Prior to reconfiguration, make sure you remove any leftovers from
the previous build.

④执行make并重定向到makeLog.txt

命令为:make -j4 2>&1 | tee makeLog.txt

这个过程时间比较久,根据电脑性能,半个小时到六个小时不等。执行完成后的makeLog.txt如下,可以打开makeLog.txt,检索是否有error,如果没有,那就顺利编译通过啦!!!

-----------------------------------------------------------------------------------------
前面省略26571行
-----------------------------------------------------------------------------------------make[4]: Leaving directory '/home/admin/Qt_Env/Qt_opensource/qt-everywhere-opensource-src-5.9.6/qtnetworkauth/examples/oauth/twittertimeline'
make[3]: Leaving directory '/home/admin/Qt_Env/Qt_opensource/qt-everywhere-opensource-src-5.9.6/qtnetworkauth/examples/oauth'
make[2]: Leaving directory '/home/admin/Qt_Env/Qt_opensource/qt-everywhere-opensource-src-5.9.6/qtnetworkauth/examples'
make[1]: Leaving directory '/home/admin/Qt_Env/Qt_opensource/qt-everywhere-opensource-src-5.9.6/qtnetworkauth'

⑤执行make install安装命令,并重定向到installLog.txt

命令为:make install 2>&1 | tee installLog.txt

installLog.txt的内容如下,打开文件检测是否有error。

-------------------------------------------------------------------------------------------
前面省略13492行
-------------------------------------------------------------------------------------------make[2]: Leaving directory '/home/admin/Qt_Env/Qt_opensource/qt-everywhere-opensource-src-5.9.6/qttranslations/translations'
make[1]: Leaving directory '/home/admin/Qt_Env/Qt_opensource/qt-everywhere-opensource-src-5.9.6/qttranslations'
cd qtdoc/ && ( test -e Makefile || /home/admin/Qt_Env/Qt_opensource/qt-everywhere-opensource-src-5.9.6/qtbase/bin/qmake -o Makefile /home/hytera/Qt_Env/Qt_opensource/qt-everywhere-opensource-src-5.9.6/qtdoc/qtdoc.pro ) && make -f Makefile install
make[1]: Entering directory '/home/admin/Qt_Env/Qt_opensource/qt-everywhere-opensource-src-5.9.6/qtdoc'
cd doc/ && ( test -e Makefile || /home/admin/Qt_Env/Qt_opensource/qt-everywhere-opensource-src-5.9.6/qtbase/bin/qmake -o Makefile /home/admin/Qt_Env/Qt_opensource/qt-everywhere-opensource-src-5.9.6/qtdoc/doc/doc.pro ) && make -f Makefile install
make[2]: Entering directory '/home/admin/Qt_Env/Qt_opensource/qt-everywhere-opensource-src-5.9.6/qtdoc/doc'
make[2]: Nothing to be done for 'install'.
make[2]: Leaving directory '/home/admin/Qt_Env/Qt_opensource/qt-everywhere-opensource-src-5.9.6/qtdoc/doc'
make[1]: Leaving directory '/home/admin/Qt_Env/Qt_opensource/qt-everywhere-opensource-src-5.9.6/qtdoc'

完成这一步,qt编译成功。


4. 将qt移植到arm开发板并运行example程序

这一部分内容较多,将在博主的另一篇博文中介绍。

Qt移植:Ubuntu16.04 交叉编译qt5.9.6详细教程相关推荐

  1. mongodb安装教程Linux,Ubuntu16.04手动安装MongoDB的详细教程

    我最近在研究MongoDB的路上,那么今天也算个学习笔记吧!今天用Ubuntu16.04手动安装MongoDB,分享给大家 注意事项: 仔细按步骤阅读操作 注意别写错字 牢记上面两点 一.用自带的火狐 ...

  2. win10+ubuntu16.04双硬盘双系统安装详细教程

    历经挫折,都装了双系统,有单硬盘的有双硬盘的,把教程贴上来. 1.首先:UltraISO(软碟通)制作U盘启动盘完整教程(附网盘软碟通资源及ubuntu16.04镜像) 里面有教程和资源https:/ ...

  3. 【Ubuntu】Ubuntu16.04+VMware+Win10安装及配置教程

    Ubuntu16.04+VMware+Win10安装及配置教程   前言:   我之所以使用Ubuntu16.4,既为学Linux操作,也为学习Python.Ubuntu16.4一直以来在虚拟机上都跑 ...

  4. ubuntu15.04配置php,Linux_Ubuntu 15.04上安装Justniffer的详细教程,Justniffer 是一个可用于替代 Snor - phpStudy...

    Ubuntu 15.04上安装Justniffer的详细教程 Justniffer 是一个可用于替代 Snort 的网络协议分析器.它非常流行,可交互式地跟踪/探测一个网络连接.它能从实时环境中抓取流 ...

  5. 【Qt】ubuntu14.04.5 qt5.6中使用opencv3.4报错:Using GTK+ 2.x and GTK+ 3 in the same process is not supported

    问题描述 ubuntu14.04.5 qt5.6中使用opencv3.4报错: Using GTK+ 2.x and GTK+ 3 in the same process is not support ...

  6. python3.6.5安装-Ubuntu16.04安装python3.6.5详细步骤

    下载python3.6.5安装包 1. 上传安装包.打开终端,利用命令cd 进入文件所在文件夹里 python@ubuntu:~/workspace$pwd /home/python/workspac ...

  7. faster-rcnn在ubuntu16.04环境下的超级详细的配置(转)

    首先,下载好必须要的安装包.为了方便,我已经全部上传在了百度云. - ubuntu16.04系统 链接:http://pan.baidu.com/s/1geU8piz 密码:25mk - cuda8. ...

  8. faster-rcnn在ubuntu16.04环境下的超级详细的配置

    首先,下载好必须要的安装包.为了方便,我已经全部上传在了百度云. - ubuntu16.04系统 链接:http://pan.baidu.com/s/1geU8piz 密码:25mk - cuda8. ...

  9. Ubuntu16.04环境下PyTorch简易安装教程

    安装NVIDIA GPU显卡驱动 如果需要安装cuda版本的PyTorch,电脑也有独立显卡的时候,一般需要更新一下Ubuntu独立显卡驱动.否则即使安装了cuda版本的PyTorch也没办法使用GP ...

最新文章

  1. 【学习笔记】超简单的多项式开方
  2. -jar参数运行应用时classpath的设置方法
  3. BSGS扩展BSGS
  4. 腾讯电脑管家13内测版官方下载地址
  5. 图像内复制粘贴篡改取证matlab_[论文笔记] 篡改检测:RGB-N
  6. 果然十三香!苹果全球销量超越小米重回第二,第一还是它
  7. OpenGL基础45:光照矫正(下)之Gamma校正
  8. mysql如何给一个数据库所有表都增加一个字段?
  9. 简单python程序代码_几个简单的python程序分享
  10. 许愿墙|爱墙 js代码
  11. 深入解析互联网协议的原理
  12. Java线程同步和锁定
  13. 【PotPlayer】敲好用的本地视频播放器
  14. CISP证书有什么作用?考试难度大吗?
  15. 安装KeMotion3 03.16d时遇到的问题
  16. iphone计算机同样答案,学会这4招,iPhone搭配Windows电脑一样好用
  17. 全志定制编译Android,全志H3 Android定制化文档
  18. 总算有人讲明白了什么是特性阻抗什么是阻抗匹配
  19. 解决线上概率性异常 TransactionTooLargeException
  20. 网贷逾期可怕吗?如果通知到朋友会怎么样?

热门文章

  1. html展示图片的两中方式
  2. IntelliJ IDEA运行JDK 19-ea问题
  3. 强化学习算法求解借贷问题
  4. 2021年上半年软件设计师上午真题及答案
  5. 3D坐标入门之——甜甜圈篇
  6. 记录一个问题xxx: no Go source files
  7. 手把手教你做测试分析
  8. 富文本编辑器复制粘贴word
  9. 【Android-音乐类】音友 免费下载、试听、全网最全的音乐 还不快来白嫖~
  10. 上升沿触发与下降沿触发