从终端进入qt压缩文件存放目录, 执行命令进行解压缩
tar xf qt-everywhere-src-6.5.2.tar.xz
进入qt-everywhere-src-6.5.2目录
cd qt-everywhere-src-6.5.2
由于Ubuntu可能是新安装的, 缺少一些库环境, 解决方式:
sudo apt-get install bison build-essential flex ruby libasound2-dev libbz2-dev libcups2-dev libdrm-dev libegl1-mesa-dev libnss3-dev libpci-dev libpulse-dev libudev-dev gyp libglu1-mesa-dev libfontconfig1-dev libx11-xcb-dev libicu-dev
运行./configure包目录中的脚本进行配置构建
./configure
默认情况下,Qt 配置为安装在该/usr/local/Qt-6.5.2目录中。这可以通过使用选项来更改-prefix。
./configure运行成功, 继续构建库和工具:
cmake --build . --parallel
构建后,在适当的位置安装库和工具
sudo cmake --install .
检查库环境信息
file /usr/local/Qt-6.5.2/bin/qmake
因为习惯了Mac zsh shell, 所以我在Ubuntu中也配置了zsh shell. 本文主要介绍在zsh shell中配置环境变量.
为了在任意地方访问qmake,需要在zsh shell中配置全部环境变量
sudo gedit .zshrc
# Qt
export QTDIR=/usr/local/Qt-6.5.2
export PATH=$QTDIR/bin:$PATH
export MANPATH=$QTDIR/man:$MANPATH
export LD_LIBRARY_PATH=$QTDIR/lib:$LD_LIBRARY_PATH
source ~/.zshrc
cd ~
qmake --version
sudo apt install build-essential cmake ninja-build git
sudo apt install qt6-base-dev qt6-base-private-dev qt6-declarative-dev qt6-declarative-private-dev qt6-tools-dev qt6-tools-private-dev qt6-scxml-dev qt6-documentation-tools libqt6core5compat6-dev qt6-tools-dev-tools qt6-l10n-tools qt6-shader-baker libqt6shadertools6-dev qt6-quick3d-dev qt6-quick3d-dev-tools libqt6svg6-dev libqt6quicktimeline6-dev libqt6serialport6-dev
sudo apt install clang-15 clangd-15 libclang-15-dev
sudo apt install libgl1-mesa-dev libvulkan-dev libxcb-xinput-dev libxcb-xinerama0-dev libxkbcommon-dev libxkbcommon-x11-dev libxcb-image0 libxcb-keysyms1 libxcb-render-util0 libxcb-xkb1 libxcb-randr0 libxcb-icccm4
方式1:
下载Qt creator源码
解压压缩包
tar xf qt-creator-opensource-src-11.0.2.tar.xz
方式2:
git clone --recursive https://code.qt.io/qt-creator/qt-creator.git repo
进入qt-creator-opensource-src-11.0.2文件夹
cd qt-creator-opensource-src-11.0.2
开始构建Qt creator
# 如果是通过git获取的源码
cmake -G Ninja -S repo -B build -D CMAKE_BUILD_TYPE=Release
# 如果是通过下载压缩包获取的源码
cmake -G Ninja -B build -D CMAKE_BUILD_TYPE=Release
# 编译
cmake --build build
# 安装
sudo cmake --install build --prefix=/usr/local/QtCreator
现在已经构建完成了, 可以通过桌面应用图标打Qt creator
sudo gedit .zshrc
# QtCreator
export QTCREATORDIR=/usr/local/QtCreator
export PATH=$QTCREATORDIR/bin:$PATH
export LD_LIBRARY_PATH=$QTCREATORDIR/lib/qtcreator:$LD_LIBRARY_PATH
source ~/.zshrc
qtcreator
Qt环境配置完成
============
如果你有更好的方法,能使点击Qt Creator应用图标来打开Qt Creator, 请告诉我, 感谢(Thanks♪(・ω・)ノ)