安装arm_qt交叉编译环境(亲测有效)

本文详细介绍了如何下载和配置Linaro编译器以支持32位ARM平台,包括版本选择、解压与安装步骤,以及如何针对Qt进行定制编译,以确保Qt项目的顺利运行。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

1、下载编译器Linaro Releases

Linaro Releases
在这里插入图片描述这里面的版本特别多,对应的版本都会不一样,如下图
在这里插入图片描述

需要看arm开发板是32位的还是64位的,我用的开发板是32位的,所以我下载的是gcc-linaro-7.5.0-2019.12-x86_64-arm-linux-gnueabihf.tar.xz
在这里插入图片描述下载完成后,将其解压:

 tar -xvf gcc-linaro-7.5.0-2019.12-x86_64_arm-linux-gnueabihf.tar.xz

重命名:

mv gcc-linaro-7.5.0-2019.12-x86_64_arm-linux-gnueabihf arm-linux-gnueabihf

将目标复制到/opt目录下:

sudo cp -rf arm-linux-gnueabihf/ /opt

安装完成后,还需要手动添加环境变量:

sudo gedit /etc/profile

将下面一行代码加入到/etc/profile的最下面:

export PATH="/opt/arm-linux-gnueabihf/bin:$PATH"

保存退出后执行下面命令,使环境变量生效:

source /etc/profile

可以检查一下有没有安装成功:

arm-linux-gnueabihf-g++ -v

显示如下,即证明安装成功:
在这里插入图片描述

2、下载qt-everywhere-src-5.14.2.tar.xz

注意:必须下载与自己qt版本对于的qt-everywhere,这里我下载的是:
qt-everywhere-src-5.14.2.tar.xz

下载完成后,解压:

tar xvf qt-everywhere-src-5.14.2.tar.xz

修改/qt-everywhere-src-5.14.2/qtbase/mkspecs/linux-arm-gnueabi-g++/qmake.conf文件,需要将编译器的具体路径加上去,具体修改如下:
在这里插入图片描述执行configure,进入路径qt-everywhere-src-5.14.2中,执行configure命令,具体参数如下:

./configure -release -nomake examples -no-iconv -no-opengl -no-assimp -no-qt3d-profile-jobs -no-qt3d-profile-gl -xplatform linux-arm-gnueabi-g++ -prefix /home/wh/qt5.14.2/qt5.14.2-arm32 -opensource -confirm-license

这里,有很多配置项,简单说明下:
-prefix选项后面的路径就是自己建的一个文件夹,用来存放编译后的qmake和其他一些配置文件
-xplatform linux-arm-gnueabi-g++ \ 就是指定编译的为ARM版本 还有一些参数,可以参考其它文章

生成命令:

sudo make -j4

安装命令:

sudo make install

以上是32位的,64位的过程是类似的

3、配置32位ARM交叉编译器

打开qt->项目->manage kits中的kits
c++
在这里插入图片描述g++
在这里插入图片描述qmake
在这里插入图片描述kits
在这里插入图片描述

Building on: linux-g++ (x86_64, CPU features: mmx sse sse2) Building for: linux-aarch64-gnu-g++ (arm64, CPU features: neon) Target compiler: gcc 6.3.1 Configuration: cross_compile use_gold_linker compile_examples enable_new_dtags largefile neon precompile_header shared rpath release c++11 c++14 concurrent dbus reduce_exports stl Build options: Mode ................................... release Optimize release build for size ........ no Building shared libraries .............. yes Using C standard ....................... C11 Using C++ standard ..................... C++14 Using ccache ........................... no Using gold linker ...................... yes Using new DTAGS ........................ yes Using precompiled headers .............. yes Using LTCG ............................. no Target compiler supports: NEON ................................. yes Build parts ............................ libs Qt modules and options: Qt Concurrent .......................... yes Qt D-Bus ............................... yes Qt D-Bus directly linked to libdbus .... no Qt Gui ................................. yes Qt Network ............................. yes Qt Sql ................................. yes Qt Testlib ............................. yes Qt Widgets ............................. yes Qt Xml ................................. yes Support enabled for: Using pkg-config ....................... yes udev ................................... no Using system zlib ...................... yes Qt Core: DoubleConversion ....................... yes Using system DoubleConversion ........ no GLib ................................... no iconv .................................. yes ICU .................................... no Tracing backend ........................ Logging backends: journald ............................. no syslog ............................... no slog2 ................................ no Using system PCRE2 ..................... no Qt Network: getifaddrs() ........................... yes IPv6 ifname ............................ yes libproxy ............................... no Linux AF_NETLINK ....................... yes OpenSSL ................................ yes Qt directly linked to OpenSSL ........ no OpenSSL 1.1 ............................ no DTLS ................................... yes SCTP ................................... no Use system proxies ..................... yes Qt Gui: Accessibility .......................... yes FreeType ............................... yes Using system FreeType ................ no HarfBuzz ............................... yes Using system HarfBuzz ................ no Fontconfig ............................. no Image formats: GIF .................................. yes ICO .................................. yes JPEG ................................. yes Using system libjpeg ............... yes PNG .................................. yes Using system libpng ................ no EGL .................................... no OpenVG ................................. no OpenGL: Desktop OpenGL ....................... no OpenGL ES 2.0 ........................ no OpenGL ES 3.0 ........................ no OpenGL ES 3.1 ........................ no OpenGL ES 3.2 ........................ no Vulkan ................................. no Session Management ..................... yes Features used by QPA backends: evdev .................................. yes libinput ............................... no INTEGRITY HID .......................... no mtdev .................................. no tslib .................................. no xkbcommon .............................. no X11 specific: XLib ................................. no EGL on X11 ........................... no QPA backends: DirectFB ............................... no EGLFS .................................. no LinuxFB ................................ yes VNC .................................... yes Mir client ............................. no Qt Sql: SQL item models ........................ yes Qt Widgets: GTK+ ................................... no Styles ................................. Fusion Windows Qt PrintSupport: CUPS ................................... no Qt Sql Drivers: DB2 (IBM) .............................. no InterBase .............................. no MySql .................................. no OCI (Oracle) ........................... no ODBC ................................... no PostgreSQL ............................. no SQLite2 ................................ no SQLite ................................. yes Using system provided SQLite ......... no TDS (Sybase) ........................... no Qt Testlib: Tester for item models ................. yes Qt SerialBus: Socket CAN ............................. yes Socket CAN FD .......................... yes Qt QML: QML network support .................... yes QML debugging and profiling support .... yes QML sequence object .................... yes QML list model ......................... yes QML XML http request ................... yes QML Locale ............................. yes QML delegate model ..................... yes Qt Quick: Direct3D 12 ............................ no AnimatedImage item ..................... yes Canvas item ............................ yes Support for Qt Quick Designer .......... yes Flipable item .......................... yes GridView item .......................... yes ListView item .......................... yes TableView item ......................... yes Path support ........................... yes PathView item .......................... yes Positioner items ....................... yes Repeater item .......................... yes ShaderEffect item ...................... yes Sprite item ............................ yes Qt Scxml: ECMAScript data model for QtScxml ...... yes Qt Gamepad: SDL2 ................................... no Qt 3D: Assimp ................................. yes System Assimp .......................... no Output Qt3D Job traces ................. no Output Qt3D GL traces .................. no Use SSE2 instructions .................. no Use AVX2 instructions .................. no Aspects: Render aspect ........................ yes Input aspect ......................... yes Logic aspect ......................... yes Animation aspect ..................... yes Extras aspect ........................ yes Qt 3D Renderers: OpenGL Renderer ........................ yes Qt 3D GeometryLoaders: Autodesk FBX ........................... no Qt Wayland Client ........................ no Qt Wayland Compositor .................... no Qt Bluetooth: BlueZ .................................. no BlueZ Low Energy ....................... no Linux Crypto API ....................... no WinRT Bluetooth API (desktop & UWP) .... no Qt Sensors: sensorfw ............................... no Qt Quick Controls 2: Styles ................................. Default Fusion Imagine Material Universal Qt Quick Templates 2: Hover support .......................... yes Multi-touch support .................... yes Qt Positioning: Gypsy GPS Daemon ....................... no WinRT Geolocation API .................. no Qt Location: Qt.labs.location experimental QML plugin . yes Geoservice plugins: OpenStreetMap ........................ yes HERE ................................. yes Esri ................................. yes Mapbox ............................... yes MapboxGL ............................. no Itemsoverlay ......................... yes QtXmlPatterns: XML schema support ..................... yes Qt Multimedia: ALSA ................................... no GStreamer 1.0 .......................... no GStreamer 0.10 ......................... no Video for Linux ........................ yes OpenAL ................................. no PulseAudio ............................. no Resource Policy (libresourceqt5) ....... no Windows Audio Services ................. no DirectShow ............................. no Windows Media Foundation ............... no Qt Tools: QDoc ................................... no Qt WebEngine: Embedded build ......................... yes Pepper Plugins ......................... no Printing and PDF ....................... no Proprietary Codecs ..................... no Spellchecker ........................... yes Native Spellchecker .................... no WebRTC ................................. no Use System Ninja ....................... no Geolocation ............................ yes WebChannel support ..................... yes Use v8 snapshot ........................ yes Kerberos Authentication ................ no Building v8 snapshot supported ......... yes Use ALSA ............................... no Use PulseAudio ......................... no Optional system libraries used: re2 .................................. no icu .................................. no libwebp, libwebpmux and libwebpdemux . no opus ................................. no ffmpeg ............................... no libvpx ............................... no snappy ............................... no glib ................................. no zlib ................................. yes minizip .............................. no libevent ............................. no jsoncpp .............................. no protobuf ............................. no libxml2 and libxslt .................. no lcms2 ................................ no png .................................. no JPEG ................................. no harfbuzz ............................. no freetype ............................. no x11 .................................. no Required system libraries: fontconfig ........................... no dbus ................................. no nss .................................. no khr .................................. no glibc ................................ yes Required system libraries for qpa-xcb: libdrm ............................... no xcomposite ........................... no xcursor .............................. no xi ................................... no xrandr ............................... no xtst ................................. no Note: Also available for Linux: linux-clang linux-icc
<think>嗯,用户想在UOS系统上安装适用于arm64架构的QT交叉编译链。首先,我需要回忆一下交叉编译的基本步骤。通常交叉编译需要安装目标架构的工具链,配置QT交叉编译环境,然后编译QT库。 用户提到的UOS系统是基于Debian的,所以应该使用apt来安装工具链。根据引用[2],安装mips64el架构的工具链用的是gcc-mips64el-linux-gnuabi64,那arm64对应的应该是gcc-aarch64-linux-gnu。不过需要确认具体的包名是否正确。 然后,安装QT的源码或者预编译版本。用户可能需要从源码编译,因为需要针对arm64架构。这时候需要配置QT的编译选项,指定交叉编译工具链的路径,比如qmake.conf文件里的编译器路径。 接下来,配置环境变量,比如将交叉编译器的路径添加到PATH中。引用[3]提到用ldd检查依赖,所以安装完成后可能需要检查是否有缺失的库,比如libncurses或者libpython。 还要注意,用户可能已经安装了部分工具,但需要验证是否完整。例如,安装gcc-aarch64-linux-gnu和g++-aarch64-linux-gnu,以及可能的其他依赖库。然后,在QT的配置中指定sysroot,可能还需要安装目标系统的库到sysroot目录下。 最后,试编译一个简单的QT程序,用生成的qmake来生成Makefile,并用交叉编译器进行编译,验证是否生成arm64的可执行文件。可能遇到的问题包括依赖库缺失、路径配置错误或者QT配置选项不正确,这时候需要根据错误信息调整配置或安装缺失的包。</think>以下是在统信UOS系统中配置ARM64架构QT交叉编译工具链的步骤: ### 一、安装基础编译工具链 1. 安装ARM64交叉编译器 ```bash sudo apt install gcc-aarch64-linux-gnu sudo apt install g++-aarch64-linux-gnu ``` 这会安装基础C/C++交叉编译器[^2][^3] 2. 验证安装 ```bash aarch64-linux-gnu-gcc -v ``` ### 二、准备QT开发环境 1. 下载QT源码包(建议5.15或6.x版本) ```bash wget https://download.qt.io/archive/qt/5.15/5.15.2/single/qt-everywhere-src-5.15.2.tar.xz tar -xvf qt-everywhere-src-5.15.2.tar.xz ``` 2. 创建编译目录 ```bash mkdir qt-build-arm64 && cd qt-build-arm64 ``` ### 三、配置交叉编译参数 1. 创建工具链配置文件 ```bash vim qt-arm64-toolchain.conf ``` 添加以下内容: ```makefile MAKEFILE_GENERATOR = UNIX CONFIG += incremental QMAKE_INCREMENTAL_STYLE = sublib QT_QPA_DEFAULT_PLATFORM = linuxfb QMAKE_CFLAGS_RELEASE += -O2 -march=armv8-a QMAKE_CXXFLAGS_RELEASE += -O2 -march=armv8-a # 交叉编译器配置 COMPILER_PATH = /usr/bin/ CROSS_COMPILE = aarch64-linux-gnu- ``` 2. 配置QT编译参数 ```bash ../qt-everywhere-src-5.15.2/configure -prefix /opt/qt5-arm64 \ -xplatform linux-aarch64-gnu-g++ \ -device-option CROSS_COMPILE=aarch64-linux-gnu- \ -sysroot / \ -opensource -confirm-license \ -no-opengl \ -qt-zlib \ -qt-libjpeg \ -qt-libpng \ -qt-freetype \ -qt-pcre \ -no-dbus ``` ### 四、编译安装 ```bash make -j$(nproc) sudo make install ``` ### 五、环境变量配置 在~/.bashrc中添加: ```bash export PATH=/opt/qt5-arm64/bin:$PATH export QT_PATH=/opt/qt5-arm64 ``` ### 六、验证安装 ```bash qmake -query # 应显示ARM架构相关路径 ```
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值