ARM64安装qt编译器和qtcreator

前言

现在网上很多关于qt安装的教程,但是大部分都是直接通过安装包安装,对于ARM64架构的系统,这种方式并不适用。

本文使用的是qt5.14.2和qtcreator4.11.1。

获取Linux系统架构

使用 uname -m查看系统架构,如下图:
在这里插入图片描述

流程

安装编译器–>安装依赖–>编译安装qt–>安装qtcreator

安装编译器

编译器安装教程

安装依赖

安装依赖参考网站
网站整理:

sudo apt-get install build-essential perl python3 git
sudo apt-get install '^libxcb.*-dev' libx11-xcb-dev libglu1-mesa-dev libxrender-dev libxi-dev libxkbcommon-dev libxkbcommon-x11-dev
sudo apt-get install flex bison gperf libicu-dev libxslt-dev ruby
sudo apt-get install libxcursor-dev libxcomposite-dev libxdamage-dev libxrandr-dev libxtst-dev libxss-dev libdbus-1-dev libevent-dev libfontconfig1-dev libcap-dev libpulse-dev libudev-dev libpci-dev libnss3-dev libasound2-dev libegl1-mesa-dev gperf bison nodejs
sudo apt-get install libasound2-dev libgstreamer1.0-dev libgstreamer-plugins-base1.0-dev libgstreamer-plugins-good1.0-dev libgstreamer-plugins-bad1.0-dev
sudo apt install clang libclang-dev

编译安装qt

qt不在维护本版
qt在维护版本
注意下载的时候需要下载源代码,解压进行编译。
进去网址后,选择single文件夹
我这里选择的是QT5.14.2
选择tar.xz压缩包
我这里选择的是QT5.14.2
下载后进行解压在opt文件夹中

sudo tar -xvf qt-everywhere-src-5.14.2.tar.xz -C /opt/

解压完成后进入文件夹,并建立auto.sh脚本文件。

sudo mkdir auto.sh
sudo chmod 755 auto.sh
sudo vim auto.sh
#! /bin/bash
./configure -prefix /opt/Qt/ \
-opensource -confirm-license \
-nomake examples \
-nomake tests \
-release \
-skip qt3d \
-skip qtcharts \
-skip qtandroidextras \
-skip qtlocation \
-skip qtmultimedia \
-skip qtsensors \
-skip qtserialbus \
-skip qtserialport \
-skip qtwayland \
-skip qtwebengine \

保存执行脚本文件

sudo ./auto.sh

脚本是为了执行./configure
-prefix /opt/Qt/ \ Qt安装路径
-opensource -confirm-license \ 安装版本,社区版还是商业版
-nomake examples \ 不编译安装例子
-nomake tests \ 不编译安装测试
-release \ release编译
-skip qt3d \ 跳过编译模块
-skip qtcharts \ 跳过编译模块
-skip qtandroidextras \ 跳过编译模块
-skip qtlocation \ 跳过编译模块,此模块容易出错
-skip qtmultimedia \ 跳过编译模块
-skip qtsensors \ 跳过编译模块
-skip qtserialbus \ 跳过编译模块
-skip qtserialport \ 跳过编译模块
-skip qtwayland \ 跳过编译模块
-skip qtwebengine \ 跳过编译模块,此模块容易出错

qtlocation qtwebengine ,如果不是特别需要这两个模块,建议放弃编译
这些命令在解压后的README中有说明
执行后根据提示进行改进,大部分提示错误是依赖安装不全

执行

sudo make -j4

这个执行时间非常长,一般在4-12小时左右,编译内容越多执行时间越长,所以上面放弃编译例子和测试。
完成后执行

sudo make install

此命令会将程序安装在/opt/Qt/ 中。
安装成功后修改环境变量:

sudo vim /etc/profile
export QTDIR=/opt/Qt
export PATH=$QTDIR/bin:$PATH
export MANPATH=$QTDIR/man:$MANPATH
export LD_LIBRARY_PATH=$QTDIR/lib:$LD_LIBRARY_PATH
source /etc/profile/

最后执行qmake -v
安装成功

编译安装qtcreator

安装qtcreator必须先安装Qt,用Qt编译qtcreator,如果编译Qt出错,这个位置编译也会出错。如果Qt编译时,有未编译的模块或者含有不依赖的模块,qt编译不受影响,但是qtcreator会有影响。我试过加-no-opengl \,编译qt没有错误,安装也可以,编译qtcreator出错。

Qtcreator最好和Qt版本相对应
Qtcreator源码下载
在这里插入图片描述
下载完成后解压
这里默认上面教程以完成好以后:
进入解压路径,执行qmaek -r等待完成后生成MakeFile文件。
然后执行sudo make -j4
等待编译完成后,执行sudo make install
执行完以后文件夹显示内容
在这里插入图片描述
打开bin文件夹就会有qtcreator和qtcreator.sh
执行./qtcreator.sh &
这样qtcreator会在后台运行。
最后配置qtcreator即可。
工具—>选项—>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
arm64架构的Debian系统上使用Qt进行音频播放的基本步骤如下: 1. 首先,确保你的系统已经安装Qt开发环境和必要的音频库。你可以使用apt-get命令来安装它们: ``` sudo apt-get install qt5-default libqt5multimedia5 libqt5multimedia5-plugins libqt5multimedia5-examples ``` 2. 创建一个Qt项目,可以使用Qt Creator创建一个新的Qt Quick Application。在项目设置中,确保你选择了正确的编译器和配置。 3. 在你的Qt项目中添加一个音频播放控件,可以使用Qt Multimedia模块提供的QMediaPlayer类。你可以在Qt Creator的设计器中拖放一个QMediaPlayer组件到你的窗口中,或者在代码中创建它。 ```cpp // 创建一个QMediaPlayer对象 QMediaPlayer* mediaPlayer = new QMediaPlayer(this); // 设置要播放的音频文件 mediaPlayer->setMedia(QUrl::fromLocalFile("/path/to/audio/file.mp3")); ``` 4. 设置音频播放相关的控制和属性。你可以使用QMediaPlayer提供的接口来控制音量、播放状态和其他属性。 ```cpp // 设置音量 mediaPlayer->setVolume(50); // 播放音频 mediaPlayer->play(); // 暂停播放 mediaPlayer->pause(); // 停止播放 mediaPlayer->stop(); ``` 5. 处理音频播放的信号。QMediaPlayer会发出一些信号,如stateChanged()、positionChanged()和durationChanged(),你可以连接这些信号来处理播放状态的变化或其他操作。 ```cpp connect(mediaPlayer, &QMediaPlayer::stateChanged, [=](QMediaPlayer::State newState){ // 处理播放状态变化的逻辑 }); ``` 6. 编译和运行你的项目。你可以在Qt Creator的构建设置中选择适合你的arm64平台进行编译,并在设备上运行你的应用程序。 以上是在arm64 Debian系统上使用Qt进行音频播放的基本步骤。你可以进一步探索Qt Multimedia模块的文档和示例来实现更复杂的音频播放功能。
评论 13
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

布丁小站

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值