在Ubuntu16 ARM64上编译Qt5.15.2,需要进行以下步骤:
- 安装编译工具链和依赖项
sudo apt-get update sudo apt-get upgrade sudo apt-get install build-essential sudo apt-get install libfontconfig1-dev libdbus-1-dev libfreetype6-dev libicu-dev libinput-dev libxkbcommon-dev libssl-dev libpng-dev libjpeg-dev libglib2.0-dev zlib1g-dev libsqlite3-dev libxslt-dev libxml2-dev libbz2-dev libssl-dev libicu-dev libharfbuzz-dev libjpeg-dev libpng-dev libwebp-dev libwebsockets-dev libmysqlclient-dev libpq-dev libiodbc2-dev libsqlite3-dev unixodbc-dev libgstreamer1.0-dev libgstreamer-plugins-base1.0-dev gstreamer1.0-plugins-base gstreamer1.0-plugins-good gstreamer1.0-plugins-bad gstreamer1.0-plugins-ugly libpulse-dev libasound2-dev libavcodec-dev libavformat-dev libswscale-dev libgl1-mesa-dev libegl1-mesa-dev libgles2-mesa-dev libgstreamer-plugins-base1.0-dev libgstreamer-plugins-good1.0-dev libgstreamer-plugins-bad1.0-dev
- 下载Qt5.15.2源码
bash<button class="flex items-center ml-auto gap-2 copy-button" data-copy-text="wget%20https%3A%2F%2Fdownload.qt.io%2Farchive%2Fqt%2F5.15%2F5.15.2%2Fsingle%2Fqt-everywhere-src-5.15.2.tar.xz%0Atar%20-xvf%20qt-everywhere-src-5.15.2.tar.xz%0Acd%20qt-everywhere-src-5.15.2">Copy code</button>
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 cd qt-everywhere-src-5.15.2
- 配置Qt编译选项
./configure -prefix /usr/local/qt5.15.2 -opensource -confirm-license -nomake examples -nomake tests -no-pch -no-gbm -opengl es2 -device linux-generic-g++ -device-option CROSS_COMPILE=/usr/bin/aarch64-linux-gnu- -sysroot /usr/aarch64-linux-gnu -skip qtwayland -skip qtwebengine -skip qtwebview -skip qtlocation -skip qtpurchasing -skip qtwebsockets -skip qtdatavis3d -skip qtcharts -skip qtlottie
其中,-prefix
为Qt的安装路径,-opengl
设置为es2表示使用OpenGL ES 2.0,-device
和-device-option
是指定编译目标设备为通用的ARM64(linux-generic-g++),并指定交叉编译工具链。 4. 开始编译
make -j$(nproc)
其中,-j$(nproc)
表示使用所有可用的CPU核心进行编译。 5. 安装Qt
sudo make install
- 配置环境变量 将以下内容添加到
/etc/environment
文件中:
QTDIR="/usr/local/qt5.15.2" PATH="$QTDIR/bin:$PATH" LD_LIBRARY_PATH="$QTDIR/lib:$LD_LIBRARY_PATH"
- 使环境变量生效
source /etc/environment
- 测试Qt是否成功安装
qmake -v
如果输出Qt的版本信息,则表示Qt已成功安装。 以上是在Ubuntu16 ARM64上编译Qt5.15.2的步骤,由于不同的环境配置和设备可能会有所不同,建议在操作前先备份重要数据,以免误操作导致数据丢失。