Ubuntu 18 下载和编译 Qt5 源码
下载源码
wget https://mirrors.aliyun.com/qt/archive/qt/5.15/5.15.2/single/qt-everywhere-src-5.15.2.tar.xz
解压缩
tar -xf qt-everywhere-src-5.15.2.tar.xz -C /tmp/
cd /tmp/qt-everywhere-src-5.15.2
配置并编译
./configure -prefix /home/deepano-ubuntu-18/bin/qt-bin -release -opensource -confirm-license -nomake examples -nomake tests
make -j$(nproc)
/home/deepano-ubuntu-18/bin/qt-bin
是自定义目录,可选择为默认的目录 '/usr/local/bin' 或者 '/usr/bin/' 等
安装
make install
添加环境变量
在 .bashrc 文件末尾添加环境配置参数
export PATH=/usr/local/qt5/bin:$PATH
export LD_LIBRARY_PATH=/usr/local/qt5/lib:$LD_LIBRARY_PATH
export PATH=/home/deepano-ubuntu-18/bin/qt-bin:$PATH
export LD_LIBRARY_PATH=/home/deepano-ubuntu-18/bin/qt-bin:$LD_LIBRARY_PATH
使配置生效
source ~/.bashrc