[Qt5] 减少dll依赖和大小(特别是webkit的大小和依赖)
Qt5的依赖太多, 而且很dll非常大. 折腾了好久, 摸索了一些精简的方法.
webkit是个非常蛋疼的东西, 依赖超多, 又很庞大. 所以需不需要webkit是完全不同的.
如何编译Qt5可以参考本人之前一篇文章 http://www.cnblogs.com/lingdhox/p/3457419.html
一.
1. 在configure时去掉不需要的模块, 比如openssl, icu等.
configure -opensource -developer-build -mp -platform win32-msvc2010 -nomake examples -nomake tests -no-icu -no-openssl -no-iconv -no-qml-debug -no-plugin-manifests
更多参数可以configure -help 查看
-no-plugin-manifests 去掉插件dll的manifests文件
需要注意: 如果要使用webkit, 那么icu是必须的.
2. 在configure时, 指定qconfig文件
该方法在嵌入式中使用较多, Qt支持feature裁剪.
在qtbase\src\corelib\global\下有一些qconfig-xxx.h的文件, 就是指定了不同的feature.
Qt tools下有个工程qttools\src\qtconfig , 编译这个项目, 运行后, 是一个图形化的裁剪feature工具. 它打开qtbase\src\corelib\global\下的qfeatures.txt, 然后你可以自由选择需要的feature, 保存成qconfig-myconfig.h
然后在运行configure时. 添加 -qconfig myconfig
我试过这个方法, 但结果是有些地方引用头文件出错. 而且没有用到feature很少, 就不深入研究了.
3. 去掉webkit的quick qml printsupport sensors Qt5V8依赖, 并裁剪webkit本身的大小
打开qtwebkit\Tools\qmake\mkspecs\features下的configure.prf 、features.prf和features.pri
features.prf中注释这四行(加#)
#haveQtModule(quick): WEBKIT_CONFIG += have_qtquick
#else: CONFIGURE_WARNINGS += "QtQuick module not found, QML APIs will not be built" #haveQtModule(printsupport): WEBKIT_CONFIG += have_qtprintsupport
#haveQtModule(sensors): WEBKIT_CONFIG += orientation_events device_orientation
这样编译出来的webkit.dll不依赖quick qml printsupport sensors
features.prf中这几行config
config_libxml2: WEBKIT_CONFIG += use_libxml2
config_libxslt: WEBKIT_CONFIG += xslt
config_libzlib: WEBKIT_CONFIG += use_zlib
config_libwebp: WEBKIT_CONFIG += use_webp
的定义在qtCompileTest中
qtbase\mkspecs\features\configure.prf下的解释
# Try to build the test project in $$QMAKE_CONFIG_TESTS_DIR/$$
# ($$_PRO_FILE_PWD_/config.tests/$$ by default).
#
# If the test passes, config_$$ will be added to CONFIG.
# The result is automatically cached. Use of cached results
# can be suppressed by passing CONFIG+=recheck to qmake.
#
# Returns: true iff the test passes
defineTest(qtCompileTest) {
positive = config_$$
done = done_config_$$
done_config_$$1会输出到.qmake.cache
比如qtimageformats\qtimageformats.pro 中添加libwebp
requires(qtHaveModule(gui)) load(configure)
qtCompileTest(jasper)
qtCompileTest(libmng)
qtCompileTest(libtiff)
qtCompileTest(libwebp) load(qt_parts)
configure.prf 中把
WEBKIT_CONFIG += \
build_webkit1 \
build_webkit2 \
build_tests \
$$WEBKIT_TOOLS_CONFIG
改成
WEBKIT_CONFIG += \
build_webkit1 \
build_tests \
$$WEBKIT_TOOLS_CONFIG
不编译webkit2 , webkit2依赖Qt5V8, 提升HTML5 , js, qml 的支持. 并提升性能.
需不需要就看情况了
features.pri 中一堆宏, 用于控制特性. 需要自己检查那些特性不需要.
注意: 这三个文件的修改要在编译前.
qtwebkit\makefile是在.\makefile中编译module-qtwebkit时动态生成的(不存在才会生成)
所以如果修改三个文件后, 想重新编译, 需要删除webkit下新生成的所有makefile
makefile source\Makefile.api
source\Makefile.api.Debug
source\Makefile.api.Release
source\Makefile.widgetsapi
source\Makefile.widgetsapi.Debug
source\Makefile.widgetsapi.Release
source\Makefile.QtWebKit source\JavaScriptCore\Makefile.jsc
source\JavaScriptCore\Makefile.jsc.Debug
source\JavaScriptCore\Makefile.jsc.Release
source\JavaScriptCore\Makefile.LLIntOffsetsExtractor
source\JavaScriptCore\Makefile.LLIntOffsetsExtractor.Debug
source\JavaScriptCore\Makefile.LLIntOffsetsExtractor.Release
source\JavaScriptCore\Makefile.JavaScriptCore.DerivedSources
source\JavaScriptCore\Makefile.JavaScriptCore
Makefile.JavaScriptCore.Target
Makefile.JavaScriptCore.Target.Debug
Makefile.JavaScriptCore.Target.Release Source\WebCore\Makefile.WebCore.DerivedSources
Source\WebCore\Makefile.WebCore.Target
Source\WebCore\Makefile.WebCore.Target.Debug
Source\WebCore\Makefile.WebCore.Target.Release
Source\WebCore\Makefile.WebCore
Source\WebKit\Makefile.WebKit1
Source\WebKit\Makefile.WebKit1.Debug
Source\WebKit\Makefile.WebKit1.Release
Source\WebKit2\Makefile.WebKit2.DerivedSources
Source\WebKit2\Makefile.WebProcess
Source\WebKit2\Makefile.WebProcess.Debug
Source\WebKit2\Makefile.WebProcess.Release
Source\WebKit2\Makefile.WebKit2.Target
Source\WebKit2\Makefile.WebKit2.Target.Debug
Source\WebKit2\Makefile.WebKit2.Target.Release
Source\WebKit2\Makefile.WebKit2
source\wtf\Makefile.WTF
source\wtf\Makefile.WTF.Debug
source\wtf\Makefile.WTF.Release
Source\ThirdParty\ANGLE\Makefile.ANGLE.Target
Source\ThirdParty\ANGLE\Makefile.ANGLE.Target.Debug
Source\ThirdParty\ANGLE\Makefile.ANGLE.Target.Release
Source\ThirdParty\ANGLE\Makefile.ANGLE
Source\ThirdParty\ANGLE\Makefile.ANGLE.DerivedSources
Source\WebKit\qt\declarative\Makefile.declarative.public
Source\WebKit\qt\declarative\Makefile.declarative.public.Debug
Source\WebKit\qt\declarative\Makefile.declarative.public.Release
Source\WebKit\qt\declarative\Makefile.declarative
Source\WebKit\qt\declarative\experimental\Makefile.declarative.experimental
Source\WebKit\qt\declarative\experimental\Makefile.declarative.experimental.Debug
Source\WebKit\qt\declarative\experimental\Makefile.declarative.experimental.Release
需要删除这些, 所以我觉得从压缩包里重新拷贝一份qtwebkit的源码出来编译, 更方便. 环境也更干净
运行 nmake module-qtwebkit 然后会生成一个.qmake.cache
打开可以看到WEBKIT_CONFIG (即刚才修改的选项)
4. 裁剪icu的大小, icudt*.dll, icuin*.dll, icuuc*.dll
http://userguide.icu-project.org/icufaq
How can I reduce the size of the ICU data library?
1). 根据官方faq的方法, 定制自己需要的数据
http://apps.icu-project.org/datacustom/
先在get data library下选择版本, 比如 ICU 51 Data
然后选择自己的需要的语言版本. 这样最后的icudt51l.dat 大概在几M左右.
2). 下载对应版本的源码包.
替换icu\source\data\in 下的icudt*l.dat
打开icu\source\allinone的VS工程
编译. 最终生成的文件icu\ 下
5. 最终生成的dll:
Qt5WebKit.dll 10M
icudt51.dll 3M
icuin51.dll 1.3M
icuuc51.dll 1M
[Qt5] 减少dll依赖和大小(特别是webkit的大小和依赖)的更多相关文章
- echarts生成的图表大小怎么随屏幕的大小改变自适应
最近在做图表,记录一下用到的知识点,当做自己的日记吧,会不断添加新内容 1,echarts生成的图表大小怎么随屏幕的大小改变自适应? this.chart.setOption(this.options ...
- 元素大小-偏移量(offset)客户区大小(client)滚动大小(scroll)
一.偏移量---offset 1.定位父级 在理解偏移大小之前,首先要理解offsetParent.人们并没有把offsetParent翻译为偏移父级,而是翻译成定位父级,很大原因是offsetPar ...
- rem在三星s5部分机型情况下 设置的字体大小与手机实际字体大小不一致问题
rem在三星s5部分机型情况下 设置的字体大小与手机实际字体大小不一致问题 判断是特殊机型,做特殊处理. var u=navigator.userAgent; if($(window).width() ...
- qt5.11.2+vs2017环境下配置pcl1.8.1以及第三方依赖库vtk的编译
1.准备工作 我所用的开发环境是win10下的qt5.11.2配置了vs2017的编译器,根据自己所用的VS的版本去官网下载对应版本的pcl库,如下 PCL-1.8.1-AllInOne-msvc20 ...
- ( 转 ) Android自绘字体大小paint.settextsize随分辨率大小变化
1.获取当前设备的屏幕大小 DisplayMetrics displayMetrics = new DisplayMetrics(); this.getWindowManager().getDefau ...
- C#比较时间大小 1、比较时间大小的实验
1.比较时间大小的实验 string st1="12:13"; string st2="14:14"; DateTime dt1=Convert.ToDa ...
- 实现图片大小的自动控制( 图片大小控制CSS代码)
图片大小控制CSS代码 将以下代码放到你的样式表文件中即可实现图片大小的自动控制. /*图片大小控制CSS By Tekin */img,a img{border:0;margin:0;padding ...
- 蜗牛爱课 -- iOS 设置UIButton的字体的大小、显示位置、大小
/设置按钮上的自体的大小 //[btn setFont: [UIFont systemFontSize: 14.0]]; //这种可以用来设置字体的大小,但是可能会在将来的SDK版本中去除改方法 ...
- 依赖注入及AOP简述(十二)——依赖注入对象的行为增强(AOP) .
四.依赖注入对象的行为增强(AOP) 前面讲到,依赖注入框架的最鲜明的特点就是能够提供受容器管理的依赖对象,并且可以对对象提供行为增强(AOP)功能,所以这一章我们来讨论有关AOP的话题. 1. ...
随机推荐
- reverse the string word by word
题目:Given an input string, reverse the string word by word. For example,Given s = "the sky is bl ...
- HDU5807 Keep In Touch DP
// HDU5807 Keep In Touch DP // 思路:直接暴力是O(n^6).所以要优化一下 // dp[i][j][k][0]:当前点i j k的方案数 // dp[i][j][k][ ...
- mybatis系列-10-一对一查询
10.1 需求 查询订单信息,关联查询创建订单的用户信息 10.2 resultType 10.2.1 sql语句 确定查询的主表:订单表 确定查询的关联表:用户表 关联查询 ...
- 【hbase】使用thrift with python 访问HBase
HBase 版本: 0.98.6 thrift 版本: 0.9.0 使用 thrift client with python 连接 HBase 报错: Traceback (most recent ...
- 【转】linux代码段,数据段,BSS段, 堆,栈
转载自 http://blog.csdn.net/wudebao5220150/article/details/12947445 linux代码段,数据段,BSS段, 堆,栈 网上摘抄了一些,自己组 ...
- HDU 5665 Lucky (水题)
Lucky 题目链接: http://acm.hust.edu.cn/vjudge/contest/123316#problem/G Description Chaos August likes to ...
- 通过源码学Java基础:BufferedReader和BufferedWriter
准备写一系列Java基础文章,先拿Java.io下手,今天聊一聊BufferedReader和BufferedWriter BufferedReader BufferedReader继承Writer, ...
- [iOS UI进阶 - 1] 自定义控件
A.关于Quiartz2D的一些细节 1.UIKit的工具已经封装了上下文引用,所以不用手动获取和渲染 - (void)drawRect:(CGRect)rect { [[UIColor redCol ...
- Codeforces Round #116 (Div. 2, ACM-ICPC Rules) E. Cubes (尺取)
题目链接:http://codeforces.com/problemset/problem/180/E 给你n个数,每个数代表一种颜色,给你1到m的m种颜色.最多可以删k个数,问你最长连续相同颜色的序 ...
- Simulator模拟器 硬件键盘不能输入
快捷键: Command + Shift +K