【ARM开发】交叉编译Qt源码之(0)编译Qt源码

本文介绍了如何交叉编译Qt源码以支持ARM架构设备,提供了交叉编译器和Qt源码的下载地址。内容包括安装交叉编译器、解压Qt源码、配置编译设置及执行编译过程。

本文只说明了Qt源码交叉编译的方法,编译出的Qt只支持基础库;如需ssl、gui、qml等,请关注后续。

交叉编译器下载地址:GNU Toolchain | GNU-A Downloads – Arm DeveloperDownload the The GNU Toolchain for the Cortex-A Family are integrated and validated packages featuring the GCC compiler, libraries and other GNU tools necessary for software development on devices based on the Arm Cortex-A processors or the Arm A-profile architecture.https://developer.arm.com/tools-and-software/open-source-software/developer-tools/gnu-toolchain/gnu-a/downloads

Qt源码下载地址:Index of /archive/qt/5.15/5.15.2/singleicon-default.png?t=M0H8https://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

评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值