惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

GbyAI
GbyAI
Y
Y Combinator Blog
Recent Announcements
Recent Announcements
D
Docker
Blog — PlanetScale
Blog — PlanetScale
罗磊的独立博客
美团技术团队
V
V2EX
Last Week in AI
Last Week in AI
D
DataBreaches.Net
T
The Blog of Author Tim Ferriss
宝玉的分享
宝玉的分享
Microsoft Security Blog
Microsoft Security Blog
Microsoft Azure Blog
Microsoft Azure Blog
人人都是产品经理
人人都是产品经理
M
MIT News - Artificial intelligence
P
Proofpoint News Feed
B
Blog RSS Feed
博客园_首页
B
Blog
博客园 - 叶小钗
I
InfoQ
WordPress大学
WordPress大学
L
LangChain Blog
Apple Machine Learning Research
Apple Machine Learning Research
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
A
About on SuperTechFans
The GitHub Blog
The GitHub Blog
The Register - Security
The Register - Security
MyScale Blog
MyScale Blog
云风的 BLOG
云风的 BLOG
博客园 - 司徒正美
Latest news
Latest news
W
WeLiveSecurity
T
The Exploit Database - CXSecurity.com
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
aimingoo的专栏
aimingoo的专栏
小众软件
小众软件
Cyberwarzone
Cyberwarzone
Scott Helme
Scott Helme
D
Darknet – Hacking Tools, Hacker News & Cyber Security
C
CERT Recently Published Vulnerability Notes
C
CXSECURITY Database RSS Feed - CXSecurity.com
Recent Commits to openclaw:main
Recent Commits to openclaw:main
N
News and Events Feed by Topic
S
Secure Thoughts
The Hacker News
The Hacker News
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
Google DeepMind News
Google DeepMind News

老鱼的博客

DOS 内存粗解 - 老鱼的博客 Qt Quick 编译器简介 - 老鱼的博客 在 openSUSE 底下跨平台编译 mingw64 程序 激活 Python 虚拟环境 - 老鱼的博客 如何存储密码(KDF) - 老鱼的博客 静态编译 Qt 简单教程 - 老鱼的博客 bcache 的使用 - 老鱼的博客 Linux 下超频 Ryzen 1700 - 老鱼的博客 怎么样在 virtualenv 里面使用 PyQt - 老鱼的博客
安装与编译最简 windows qt - 老鱼的博客
2020-06-11 · via 老鱼的博客

安装与编译最简 windows qt


类型:C++ & Qt4,创建时间:June 11, 2020, 11:48 a.m.

标题无“转载”即原创文章,版权所有。转载请注明来源:http://hgoldfish.com/blogs/article/109/。

Qt 为 windows 提供了一个在线安装包,以及一个巨大的离线安装包。使用在线安装包能够自由选择 Qt 版本。使用离线安装包可以在不需要网络地方或者在多台机器上使用。

但是两个安装器安装的 Qt 容量都太过于巨大了,包含了所有的 Qt 模块以及它们的 debug 信息。如果我们只使用 C++ 以及 QtWidgets 做 Qt 开发,就没必要安装那么多的组件,浪费空间。这时候可以考虑自己编译一下 Qt

首先下载 Qt 所需要的 mingw32 或者 mingw-w64. 自 Qt 5.6 以后,需要 c++11 支持,所以 Mingw32 就不能再使用了,所以我们这里下载的是 mingw64 7.3.0:

http://mirrors.ustc.edu.cn/qtproject/online/qtsdkrepository/windows_x86/desktop/tools_mingw/qt.tools.win32_mingw730/7.3.0-1-201903151311i686-7.3.0-release-posix-dwarf-rt_v5-rev0.7z

64 位的 mingw64 7.3.0

http://mirrors.ustc.edu.cn/qtproject/online/qtsdkrepository/windows_x86/desktop/tools_mingw/qt.tools.win64_mingw730/7.3.0-1x86_64-7.3.0-release-posix-seh-rt_v5-rev0.7z

下载后解压到:

C:\Qt\mingw730\

再下载 Qt 源代码:

http://mirrors.ustc.edu.cn/qtproject/official_releases/qt/5.12/5.12.5/submodules/qtbase-everywhere-src-5.12.5.zip

在这个目录里面有 .tar.xz 和 .zip 两个格式的压缩包。前者适合 linux,而后者适合 Windows. 前者其实也可以在 Windows 下编译,只是额外需要 Perl 解释器。

把这个文件解压缩到:

C:\Qt\qtbase-everywhere-src-5.12.5

然后就可以开始编译了:

首先切换目录以及把 mingw32 的命令行加入到 %PATH% 里面:

cd C:\Qt\qtbase-everywhere-src-5.12.5
path %PATH%;C:\Qt\mingw730\bin

如果是 32 位的 mingw 有个 BUG,需要修改一下 Qt 源代码。看附注。

接着开始编译。

configure.bat -prefix C:/Qt/5.12.5/ -opensource -release -shared -no-icu -opengl desktop -no-style-windowsvista  -optimize-size -nomake examples -nomake tests
mingw32-make -j4

其中-optimize-size让 qt 编译出比较小的 dll, 两个-nomake不编译 examples 和 tests 可以节省编译时间。-no-icu去掉 icu 的依赖.

编译完安装。

此外,还可以独立安装 QtCreator 而不必使用 Qt 安装包。

http://mirrors.ustc.edu.cn/qtproject/online/qtsdkrepository/windows_x86/desktop/tools_qtcreator/qt.tools.qtcreator/4.12.2-0qtcreator.7z

qtcreator 的 msvc 运行时包(一般系统里面已经有了不用安装): http://mirrors.ustc.edu.cn/qtproject/online/qtsdkrepository/windows_x86/desktop/tools_vcredist/qt.tools.vcredist_msvc2019_x86/2019-05-19-1vcredist_msvc2019_x86.7z

==========================================

附注1,32位 mingw64 有个 rdrand 的 BUG 需要修复一下

所以在编译开始之前修改这个文件:

src/corelib/global/qrandom.cpp

这段代码:

#if defined(Q_PROCESSOR_X86) && QT_COMPILER_SUPPORTS_HERE(RDRND)
static qsizetype qt_random_cpu(void *buffer, qsizetype count) Q_DECL_NOTHROW;

修改成

#if defined(Q_PROCESSOR_X86_64) && QT_COMPILER_SUPPORTS_HERE(RDRND)
static qsizetype qt_random_cpu(void *buffer, qsizetype count) Q_DECL_NOTHROW;

在 32 位的情况下降低一点安全性。

==========================================

附注2, windows vista style 需要 windows sdk,使用 mingw 不能编译通过。

所以参数里面加上了-no-style-windowsvista

标题无“转载”即原创文章,版权所有。转载请注明来源:http://hgoldfish.com/blogs/article/109/。


暂时还没有任何评论。