银河麒麟Kylin系统编译安装Qt5.12.12
一、安装环境依赖
#基础编译环境
sudo apt-get install -y build-essential perl python git
#安装Libxcb相关依赖(用于X11窗口系统)
sudo apt-get install -y '^libxcb.*-dev' libx11-xcb-dev libxcb-xinerama0-dev libglu1-mesa-dev libxrender-dev libxi-dev libxkbcommon-dev libxkbcommon-x11-dev
#安装Qt WebKit相关依赖
sudo apt-get install -y flex bison gperf libicu-dev libxslt-dev ruby
#安装Qt WebEngine相关依赖
sudo apt-get install -y libssl-dev libxcursor-dev libxcomposite-dev libxdamage-dev libxrandr-dev libdbus-1-dev libfontconfig1-dev libcap-dev libxtst-dev libpulse-dev libudev-dev libpci-dev libnss3-dev libasound2-dev libxss-dev libegl1-mesa-dev
#安装Qt Multimedia相关依赖
sudo apt-get install -y libasound2-dev libgstreamer1.0-dev libgstreamer-plugins-base1.0-dev
#安装QDoc文档生成工具依赖
sudo apt-get install -y libclang-dev llvm clang
#安装其他工具
sudo apt-get install -y re2c ninja-build
二、编译安装
cd qt-everywhere-src-5.12.12
mkdir ../build
cd ../build
/data/usershare/qt-everywhere-src-5.12.12/qt-everywhere-src-5.12.12/configure -prefix /opt/Qt5.12.12 \-platform linux-aarch64-gnu-g++ \-xplatform linux-aarch64-gnu-g++ \-release \-opensource \-confirm-license \-nomake examples \-nomake tests \-shared \-qt-libjpeg \-qt-libpng \-qt-zlib \-qt-pcre \-qt-xcb \-no-opengl \-skip webengine \-skip qtwayland\-skip qt3d\-verbose
!!!!注:上面的参数是不安装OpenGL的,如果需要OpenGL请按照下面的参数进行编译:
在编译前请检查Kylin里OpenGL的支持:dpkg -l | grep -i gles
如果输出:
ii libgles-dev:arm64 1.3.2-1~kylin0.20.04.2 arm64 Vendor neutral GL dispatch library -- GLES development files
ii libgles1:arm64 1.3.2-1~kylin0.20.04.2 arm64 Vendor neutral GL dispatch library -- GLESv1 support
ii libgles2:arm64 1.3.2-1~kylin0.20.04.2 arm64 Vendor neutral GL dispatch library -- GLESv2 support
表明平台支持OpenGL ES1.0和2.0
/data/usershare/qt-everywhere-src-5.12.12/qt-everywhere-src-5.12.12/configure \-prefix /opt/Qt5.12.12 \-platform linux-aarch64-gnu-g++ \-xplatform linux-aarch64-gnu-g++ \-release \-opensource \-confirm-license \-nomake examples \-nomake tests \-shared \-qt-xcb \-opengl es2 \-skip webengine \-qt-libjpeg \-qt-libpng \-qt-zlib \-qt-pcre \-skip qtwayland\-skip qt3d\-verbose
# -prefix <path>:指定Qt的安装目录(例如 /usr/local/Qt-5.12.12)。
#-opensource:编译开源版本。
#-confirm-license:自动确认许可。
#-nomake examples 和 -nomake tests:不编译示例和测试,显著加快编译速度。
#-shared:构建共享库(动态链接库)。
#-platform:指定宿主机的编译器(如 linux-clang)。根据你的编译器选择,例如 linux-aarch64-gnu-g++ 用于ARM64:cite[6]
#-xplatform:如果进行交叉编译,需指定目标平台的编译器(例如针对ARM64架构的编译器)。
#-skip <module>:跳过某些模块(如 -skip webengine)可以解决某些依赖问题或减少编译时间,但除非你确定不需要该模块,否则一般不推荐6。
#-no-opengl:如果遇到OpenGL相关错误,可以尝试此选项4。
#-qt-xcb:使用XCB(X11)进行图形界面渲染4
make -j$(nproc)
sudo make install
三、配置环境变量
vim ~/.bashrcexport PATH=/opt/Qt5.12.12/bin:$PATH
export LD_LIBRARY_PATH=/opt/Qt5.12.12/lib:$LD_LIBRARY_PATH
export QT_QPA_PLATFORM_PLUGIN_PATH=/opt/Qt5.12.12/plugins/platformssource ~/.bashrc
四、补充
qmake -v
sudo apt-get install qtcreator