本文只说明了Qt源码交叉编译的方法,编译出的Qt只支持基础库;如需ssl、gui、qml等,请关注后续。
Qt源码下载地址:Index of /archive/qt/5.15/5.15.2/single
https://download.qt.io/archive/qt/5.15/5.15.2/single/1、安装交叉编译器
#解压交叉编译工具
xz -d gcc-arm-10.3-2021.07-x86_64-arm-none-linux-gnueabihf.tar.xz
tar -xvf gcc-arm-10.3-2021.07-x86_64-arm-none-linux-gnueabihf.tar
2、交叉编译Qt
2.1、解压Qt源码
#解压Qt源码
xz -d qt-everywhere-src-5.15.2.tar.xz
tar -xvf qt-everywhere-src-5.15.2.tar
cd qt-everywhere-src-5.15.2
2.2、配置编译设置
cd qtbase/mkspecs
#以linux-arm-gnueabi-g++为模板,新建一个交叉编译配置
cp -r linux-arm-gnueabi-g++ linux-arm-gnueabihf-g++
cd linux-arm-gnueabihf-g++
#编辑qmake.conf
编辑 #nano qmake.conf
#
# qmake configuration for building with arm-none-linux-gnueabihf-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)
# modifications to g++.conf
QMAKE_CC = /home/user/toolchain/arm-none-linux-gnueabihf/bin/arm-none-linux-gnueabihf-gcc
QMAKE_CXX = /home/user/toolchain/arm-none-linux-gnueabihf/bin/arm-none-linux-gnueabihf-g++
QMAKE_LINK = /home/user/toolchain/arm-none-linux-gnueabihf/bin/arm-none-linux-gnueabihf-g++
QMAKE_LINK_SHLIB = /home/user/toolchain/arm-none-linux-gnueabihf/bin/arm-none-linux-gnueabihf-g++
# modifications to linux.conf
QMAKE_AR = /home/user/toolchain/arm-none-linux-gnueabihf/bin/arm-none-linux-gnueabihf-ar cqs
QMAKE_OBJCOPY = /home/user/toolchain/arm-none-linux-gnueabihf/bin/arm-none-linux-gnueabihf-objcopy
QMAKE_NM = /home/user/toolchain/arm-none-linux-gnueabihf/bin/arm-none-linux-gnueabihf-nm -P
QMAKE_STRIP = /home/user/toolchain/arm-none-linux-gnueabihf/bin/arm-none-linux-gnueabihf-strip
load(qt_config)
2.3、新建配置脚本
#进入Qt源码目录
cd qt-everywhere-src-5.15.2
#新建build文件夹,用来存放编译文件
mkdir build
cd build
#新建configure.sh配置文件
vi configure.sh
configure.sh
#! /bin/bash
#其中/path/to/prefix指编译安装目录
#如/home/user/toolchain/arm-none-linux-gnueabihf/arm-none-linux-gnueabihf
#把编译结果安装在交叉编译器中,否则引用到该库需要指定对应的目录
../configure \
-prefix /path/to/prefix \
-opensource \
-confirm-license \
-release \
-xplatform linux-arm-gnueabihf-g++ \
-make libs \
-nomake examples \
-nomake tools \
-nomake tests \
-no-openssl \
-no-opengl \
-skip qt3d \
-skip qtactiveqt \
-skip qtandroidextras \
-skip qtcharts \
-skip qtconnectivity \
-skip qtdatavis3d \
-skip qtdeclarative \
-skip qtdoc \
-skip qtgamepad \
-skip qtgraphicaleffects \
-skip qtimageformats \
-skip qtlocation \
-skip qtlottie \
-skip qtmacextras \
-skip qtmultimedia \
-skip qtnetworkauth \
-skip qtpurchasing \
-skip qtquick3d \
-skip qtquickcontrols \
-skip qtquickcontrols2 \
-skip qtquicktimeline \
-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 qtwebglplugin \
-skip qtwebsockets \
-skip qtwebview \
-skip qtwinextras \
-skip qtx11extras \
-skip qtxmlpatterns
开始编译
#执行编译脚本
./configure.sh
#编译
make
#安装
make install
本文介绍了如何交叉编译Qt源码以支持ARM架构设备,提供了交叉编译器和Qt源码的下载地址。内容包括安装交叉编译器、解压Qt源码、配置编译设置及执行编译过程。
https://developer.arm.com/tools-and-software/open-source-software/developer-tools/gnu-toolchain/gnu-a/downloads
编译Qt源码&spm=1001.2101.3001.5002&articleId=122855717&d=1&t=3&u=85f9e24e074b476e98233472cac10541)
6047

被折叠的 条评论
为什么被折叠?



