Ubuntu QT 交织编译情况搭建(超级具体)
1.准备工作(安装QT,下载交织编译工具,下载源码)一 ,安装Qt
下载安装包地址:Qt5.12.9https://csdnimg.cn/release/blog_editor_html/release2.3.8/ckeditor/plugins/CsdnLink/icons/icon-default.png?t=P1C7https://download.qt.io/archive/qt/5.12/5.12.9/qt-opensource-linux-x64-5.12.9.run这是官网下载地址,必要梯子访问,推荐复制链接到迅雷下载(非常快)
二 ,下载编译工具
交织编译工具下载地址:Linaro Releases
https://i-blog.csdnimg.cn/direct/05d5f2e8f7244e5d874a56f348d7cecc.png
下载解压/opt目次下,后修改文件/etc/profile,添加交织编译工具路径
https://i-blog.csdnimg.cn/direct/46ad47b8fcc84fbca18cbbbf286eb239.png
三 ,下载QT源码
下载地址:qt-everywhere-src-5.12.9.tar.xzhttps://csdnimg.cn/release/blog_editor_html/release2.3.8/ckeditor/plugins/CsdnLink/icons/icon-default.png?t=P1C7https://download.qt.io/archive/qt/5.12/5.12.9/single/qt-everywhere-src-5.12.9.tar.xz
2.编写config脚本执行命令创建make(配置编译Qt源码编译方案)
方式一、选择只编译Qt的基础模块(主讲源码完备编译)
源码目次下有一个qtbase目次,该目次是Qt的基础模块目次,
该目次下同样有configure文件(在源码目次下也有一个configure配置文件,这两个文件不一样)
当我们在Qt源码目次下执行./configure命令时,可以配置团体编译方案,我们则可以在此处设置
想要编译构建的参数和模块。在/qtbase目次下,执行./configure命令时,配置的是在该目次下的Qt根本模块
只编译构建qtbase,开发运行常见窗体应用是可以的
目次下新建文件autoconfigure.sh,输入以下内容构建脚本
#!/bin/sh
./configure \
-prefix /home/XXX/Downloads/qt-everywhere-src-5.14.1/arm-qt \
-confirm-license \
-opensource \
-shared \
-release \
-make libs \
-xplatform linux-arm-gnueabi-g++ \
-optimized-qmake \
-pch \
-qt-libjpeg \
-qt-libpng \
-qt-zlib \
-skip qtdeclarative \
-no-opengl \
-no-sse2 \
-no-openssl \
-no-cups \
-no-glib \
-no-dbus \
-no-xcb \
-no-separate-debug-info \
-no-fontconfig \
-nomake examples -nomake tools -nomake tests -no-iconv
exit
-prefix:该参数用于指定Qt编译完成后安装时的输出目次。
-xplatform:用于交织编译时选择目标mkspec。(需与qtbase/mkspec目次下的目次名称一样)
编辑qt源码目次下qtbase/kspecs/linux-arm-gnueabi-g++下的 qmake.conf。注意: mkspecs 下有许多平台选择,阐明白 Qt 是跨平台的。之所以是选择 linux-arm-gnueabi-g++,这是由于前面autoconfigure.sh里的参数-xplatform 选择了 linux-arm-gnueabi-g++,具体操作在方式二里操作雷同
方式二、完备编译Qt源码
1.配置autoconfigure.sh文件
完备编译Qt源码指的是在Qt源码路径下进行编译,使用configure对Qt进行编译配置时指定必要编译的模块,在源码目次下新建文件autoconfigure.sh,输入以下内容
#! /bin/sh
./configure -prefix /home/linux/work/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 \
-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/Qt/tslib-1.21/arm-tslib/include \
-L/home/Qt/tslib-1.21/arm-tslib/lib \
-recheck-all I/home/linux/work/tslib/arm-tslib/include \
-L//home/linux/work/tslib/arm-tslib/lib \
这个是嵌入式触摸屏的开源库,必要放我们本身编译的后Tslib库的路径(也可叫不加放到这里一起编译了)
编译Tslib
1 获取 tslib
本文使用的是tslib-1.21
将tslib-1.21.tar.bz2解压
sudo tar -jxvf tslib-1.21.tar.bz2
https://i-blog.csdnimg.cn/direct/1deafcb0499944e387b06121cb5d2c01.png
1.2 配置 tslib
先安装 automake 工具
sudo apt-get install autoconf automake libtool
配置源码天生 Makefile
./autogen.sh
1.3 配置交织编译工具
新建一个文件夹,用于存放编译输出的内容,在当前目次下新建,执行下面的指令
mkdir arm-tslib
获取路径
指定交织编译工具与输出路径指令为
.
/configure --host=arm-linux-gnueabihf ac_cv_func_malloc_0_nonnull=yes --cache-file=arm-linux.cache -prefix=/home/work/third-party/tslib-1.21/arm-tslib这里的的arm-linux-gnueabihf 与-cache-file=arm-linux要与我们配置交差编译器名称雷同
我的名称就是arm-none-linux-gnueabi,所以改为:
./configure --host=arm-none-linux-gnueabi ac_cv_func_malloc_0_nonnull=yes --cache-file=arm-none-linux.cache -prefix=/home/linux/work/tslib/arm-tslib
https://i-blog.csdnimg.cn/direct/284cdd08ca9b4f48bcf1cb947a342b1b.png
1.4 编译与安装
执行make编译
make -j2 //加参数-j2 是最多允许 2 条编译指令同时进行
编译完成
执行 make install 指令进行安装
make install
安装完成
https://i-blog.csdnimg.cn/direct/fc10d5b10fe14186ba3762ac70ea6326.png
将配置好的autoconfigure.sh文件添加可执行权限
https://i-blog.csdnimg.cn/direct/0c3320c9428f405487e87fb27fbb7b05.png
2.配置qmake.conf文件
编辑qt源码目次下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
include(../common/linux.conf)
include(../common/gcc-base-unix.conf)
include(../common/g++-unix.conf)
#20250305 song
QT_QPA_DEFAULT_PLATFORM = linuxfb
#该配置指定了Qt使用Linux Framebuffer(LinuxFB)作为默认的图形后端,适用于无X服务器或硬件加速的嵌入式环境。
#LinuxFB直接操作帧缓冲设备实现图形输出,需确保设备节点(如/dev/fb0)存在且权限正常
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
#-O2:启用二级优化,提升代码执行效率。
#-march=armv7-a:指定目标CPU架构为ARMv7-A系列。
#-mtune=cortex-a7:针对Cortex-A7内核进行指令调度优化。
#-mfpu=neon:启用NEON SIMD指令集加速图形和信号处理。
#-mfloat-abi=hard:使用硬件浮点运算(需CPU支持VFPv3-D16)。
#改为下载的交叉编译器目录
# modifications to g++.conf
QMAKE_CC = /opt/arm-2014.05/bin/arm-linux-gnueabihf-gcc
QMAKE_CXX = /opt/arm-2014.05/bin/arm-linux-gnueabihf-g++
QMAKE_LINK = /opt/arm-2014.05/bin/arm-linux-gnueabihf-g++
QMAKE_LINK_SHLIB = /opt/arm-2014.05/bin/arm-linux-gnueabihf-g++
# modifications to linux.conf
QMAKE_AR = /opt/arm-2014.05/bin/arm-linux-gnueabihf-ar cqs
QMAKE_OBJCOPY = /opt/arm-2014.05/bin/arm-linux-gnueabihf-objcopy
QMAKE_NM = /opt/arm-2014.05/bin/arm-linux-gnueabihf-nm -P
QMAKE_STRIP = /opt/arm-2014.05/bin/arm-linux-gnueabihf-strip
QMAKE_INCDIR += /home/linux/work/tslib/arm-tslib/include
QMAKE_LIBDIR += /home/linux/work/tslib/arm-tslib/lib
load(qt_config)
3.执行 autoconfigure.sh 配置
https://i-blog.csdnimg.cn/direct/e8e025203e5b4594b23287834c579a60.png
这里碰到一个几个大坑在执行autoconfigure.sh时要注意文件的编码格式,最好保存为UTF-8格式不然报错
https://i-blog.csdnimg.cn/direct/dd447f0817304c7b8c3a2979c229dba6.png
还有openGL模块要在autoconfigure.sh配置-no-opengl不然报错
https://i-blog.csdnimg.cn/direct/43daecfbceb34d6f99d5496bd6b67768.png
出现Just run make构建乐成
https://i-blog.csdnimg.cn/direct/1352391204d54d5f96f7c8c257b4ceb6.png
3.执行make编译
https://i-blog.csdnimg.cn/direct/0d581d4034f2479dbdc7634cf90a9fa8.png
报错在交织编译目次下没有 gun/stubs-hard文件,我们在qmake.conf文件里指定了-mfloat-abi=hard:使用硬件浮点运算,但是我的目次下没有这个文件,原因是我使用交织编译器是arm-linux-guneabi他是不带这个文件夹的
具体链接
https://i-blog.csdnimg.cn/direct/e17ea7af6e31487da737a1f18d2b228f.png
办理方法在qmake.conf去掉-mfloat-abi=hard
https://i-blog.csdnimg.cn/direct/5f3f2c0a774b490d8da4b7dafdc8a58c.png
继续make乐成编译
4.执行 make install 安装
https://i-blog.csdnimg.cn/direct/4eea0a502c884bc2b65b006438987cf3.png
5.安装结果
https://i-blog.csdnimg.cn/direct/5b0e0cbf952a42d8a57895a7d6eae9b0.png
https://i-blog.csdnimg.cn/direct/dccb16dd16f44dfda007ae35645566f1.png
6.在Qt Creator添加交织编译,创建套件
ubuntu搭建qt交织编译情况_qt交织编译情况搭建_²º²²এ松的博客-CSDN博客
7.完成搭建
构建套件完成
https://i-blog.csdnimg.cn/direct/fbb05def24d748fa8171b16f76ef6a69.png
https://i-blog.csdnimg.cn/direct/14593dd3762949d2853d7f0825c75de5.png
构建交织编译步伐天生乐成
https://i-blog.csdnimg.cn/direct/d2c9d47fd8454ae094c4b137fcda7597.png
参考文章:
[*]armlinux 移植qt
[*]ubuntu搭建qt交织编译情况
[*]将qt步伐交织编译到arm架构上香奈儿的技术博客_51CTO博客
[*]ubuntu搭建qt的arm交织编译情况_qt交织编译情况搭建-CSDN博客
[*]Ubuntu QT 交织编译情况搭建_qt交织编译情况搭建-CSDN博客
免责声明:如果侵犯了您的权益,请联系站长,我们会及时删除侵权内容,谢谢合作!更多信息从访问主页:qidao123.com:ToB企服之家,中国第一个企服评测及商务社交产业平台。
页:
[1]