从源码编译Qt5

1 需要做的前期准备

配置好C++的编译环境

  • win:推荐MSVC 也就是下载Visual Studio(建议2019)
  • linux: gcc

2 下载项目源码

  • 仓库地址:https://github.com/qt/qt5.git 把他clone下来
  • 可以自己选择需要的模块下载,例如qtbase:git submodule update --init qtbase
  • 如果需要直接下载所有的模块:git submodule update --init --recursive

3 开始编译源码

  • 需要注意是编译x86还是x64版本的,调用 x86 Native Tools Command Prompt for VS 2019 (根据自己需要编译的目标和本地的环境来进行选择)
  • win中需要的编译工具
    • Supported compiler (Visual Studio 2012 or later,
      MinGW-builds gcc 4.9 or later)
    • Perl version 5.12 or later https://strawberryperl.com/
    • Python version 2.7 or later http://www.activestate.com/activepython/
    • Ruby version 1.9.3 or later http://rubyinstaller.org/
  • linux 中就比较简单了,缺什么环境就直接 sudo apt-get install就可以了。
shell 复制代码
# 调起编译环境(只在win中需要)
call "C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Auxiliary\Build\vcvars32.bat"
# 进入源码根目录
cd qt5
# 配置编译环境
./configure -prefix <安装qt的目录>
# 我这里的安装命令是:
./configure -prefix <安装目录> -opensource -confirm-license -nomake examples -nomake tests -recheck-all
# 如果是编译单个模块:
make module-<module name>

make -j4
make install

4 编译完成

  • 编译完成后,会在安装目录下生成bin,lib,include等文件夹,大概效果如图所示:
相关推荐
xcyxiner6 小时前
DicomViewer (后台线程处理文件)4
qt
xcyxiner13 小时前
DicomViewer (添加模型类)3
qt
xcyxiner1 天前
DicomViewer (目录调整) 2
qt
xcyxiner1 天前
dcmtk vtk vtk-dicom(gdcm) 编译(debug) v2
qt
clint4562 天前
C++进阶(1)——前景提要
c++
夜悊3 天前
C++代码示例:进制数简单生成工具
c++
郝学胜_神的一滴3 天前
CMake 021: IF 条件判据详诠
c++·cmake
_wyt0013 天前
洛谷 B3930 [GESP202312 五级] 烹饪问题 题解
c++·gesp
LDR0063 天前
Type-C 快充全面升级!LDR6601 赋能个人护理便携电机,重塑剃须刀 / 理发器新体验
c语言·开发语言
雪碧聊技术3 天前
Tree.js是什么?一文讲透
开发语言·javascript·ecmascript