从源码编译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等文件夹,大概效果如图所示:
相关推荐
十五年专注C++开发9 小时前
fatal error C1189: #error: WinSock.h has already been included 的解决方案
c++·socket·boost
jimy110 小时前
C语言模拟对象、方法:“函数指针+结构体“复用函数指针指向的函数体
c语言·开发语言
天外天-亮11 小时前
HBuilder X 使用 uview-plus 方式
开发语言·javascript·hbuilder x·uview-plus
木木子2211 小时前
[特殊字符] 音乐播放器——状态驱动的多媒体控制
android·开发语言·华为·php·harmonyos
旖-旎11 小时前
《LeetCode 53 最大子数组和 || LeetCode 918 环形子数组的最大和》
c++·算法·leetcode·动态规划
六个九十度12 小时前
用python脚本访问被网关隔离的嵌入式设备
开发语言·python
酷酷的身影12 小时前
Drivers/LedManager.cs
开发语言·php
小樱花的樱花12 小时前
Linux 线程的创建
linux·c语言·开发语言
xiaoshuaishuai812 小时前
C# AI实现PR处理、单元测试
开发语言·c#·log4j
C++、Java和Python的菜鸟12 小时前
第7章 Java高级技术
java·开发语言