从源码编译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等文件夹,大概效果如图所示:
相关推荐
随流寻影1 小时前
利用 C++ 实现快速排序及三种优化
开发语言·c++
默 语1 小时前
【HarmonyOS7】ArkTS通用属性实战(六):组件级像素取整 pixelRound
开发语言
西西弗Sisyphus1 小时前
C++ 最小 Agentic Loop 实现 - 回调函数系列 - 指针与内存地址(2)
开发语言·c++
宿州派大星1 小时前
Python 音视频处理流水线:视频分离音频 + 讯飞转写 + 星火大模型解析(附完整代码与踩坑指南)
开发语言·python·音视频
烟烟Abandon2 小时前
FFmpeg开发基础之 C 语言编译器
c语言·开发语言·ffmpeg
郝学胜-神的一滴2 小时前
Effective Python 条款47:吃透惰性属性
大数据·开发语言·数据库·人工智能·python·算法·oracle
syf0611132 小时前
【Java】synchronized 关键字详解:从字节码到对象头与锁升级
java·开发语言
其实防守也摸鱼3 小时前
Day 3 · Agent Loop:从调用模型到控制循环 —— 课件精讲笔记
服务器·开发语言·javascript·数据库·人工智能·笔记·ecmascript
西西弗Sisyphus3 小时前
C++ 最小 Agentic Loop 实现 - 回调函数系列 - typedef 封装(4)
c++