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的大小和依赖)的更多相关文章

  1. echarts生成的图表大小怎么随屏幕的大小改变自适应

    最近在做图表,记录一下用到的知识点,当做自己的日记吧,会不断添加新内容 1,echarts生成的图表大小怎么随屏幕的大小改变自适应? this.chart.setOption(this.options ...

  2. 元素大小-偏移量(offset)客户区大小(client)滚动大小(scroll)

    一.偏移量---offset 1.定位父级 在理解偏移大小之前,首先要理解offsetParent.人们并没有把offsetParent翻译为偏移父级,而是翻译成定位父级,很大原因是offsetPar ...

  3. rem在三星s5部分机型情况下 设置的字体大小与手机实际字体大小不一致问题

    rem在三星s5部分机型情况下 设置的字体大小与手机实际字体大小不一致问题 判断是特殊机型,做特殊处理. var u=navigator.userAgent; if($(window).width() ...

  4. qt5.11.2+vs2017环境下配置pcl1.8.1以及第三方依赖库vtk的编译

    1.准备工作 我所用的开发环境是win10下的qt5.11.2配置了vs2017的编译器,根据自己所用的VS的版本去官网下载对应版本的pcl库,如下 PCL-1.8.1-AllInOne-msvc20 ...

  5. ( 转 ) Android自绘字体大小paint.settextsize随分辨率大小变化

    1.获取当前设备的屏幕大小 DisplayMetrics displayMetrics = new DisplayMetrics(); this.getWindowManager().getDefau ...

  6. C#比较时间大小 1、比较时间大小的实验

    1.比较时间大小的实验    string st1="12:13"; string st2="14:14"; DateTime dt1=Convert.ToDa ...

  7. 实现图片大小的自动控制( 图片大小控制CSS代码)

    图片大小控制CSS代码 将以下代码放到你的样式表文件中即可实现图片大小的自动控制. /*图片大小控制CSS By Tekin */img,a img{border:0;margin:0;padding ...

  8. 蜗牛爱课 -- iOS 设置UIButton的字体的大小、显示位置、大小

    /设置按钮上的自体的大小 //[btn setFont: [UIFont systemFontSize: 14.0]];    //这种可以用来设置字体的大小,但是可能会在将来的SDK版本中去除改方法 ...

  9. 依赖注入及AOP简述(十二)——依赖注入对象的行为增强(AOP) .

    四.依赖注入对象的行为增强(AOP) 前面讲到,依赖注入框架的最鲜明的特点就是能够提供受容器管理的依赖对象,并且可以对对象提供行为增强(AOP)功能,所以这一章我们来讨论有关AOP的话题. 1.    ...

随机推荐

  1. 【C#】字符串与字符数组

    字符串与字符数组的相互转换. 字符串转换成字符数组: string ss="abcdefg"; char[] cc=ss.ToCharArray();     字符数组转换成字符串 ...

  2. oc_转_类的数组的实现和操作

    OC的数组对象的基本方法的使用:因为OC的数组中存储的为对象类型,所以我们可以新建一个Person类,通过Person生成对象进行操作. 其中Person.h中的代码为:   01.#import&l ...

  3. [Hive - LanguageManual] VirtualColumns

    Virtual Columns Simple Examples Virtual Columns Hive 0.8.0 provides support for two virtual columns: ...

  4. HTTP知识填补

    1.HTTP协议 HTTP协议是计算机通信的一种协议 流程: 1.http客户端发起请求,例如手机访问baidu.com,创建端口,一般位80 2.http服务器在端口监听客户端请求 3.http接收 ...

  5. 无线 WIFI 的13个信道频率范围

    目前主流的无线WIFI网络设备不管是802.11b/g还是802.11b/g/n 一般都支持13个信道.它们的中心频率虽然不同,但是因为都占据一定的频率范围,所以会有一些相互重叠的情况.下面是13个信 ...

  6. Nginx的session一致性问题

    session一致性memcached缓存数据库解决方案 1.安装memcached内存数据库 yum –y install memcached 可以用telnet localhost 11211 S ...

  7. CodeForces 682D Alyona and Strings (四维DP)

    Alyona and Strings 题目链接: http://acm.hust.edu.cn/vjudge/contest/121333#problem/D Description After re ...

  8. #JAVA操作LDAP

    package com.wisdombud.unicom.monitor.ldap; import java.util.ArrayList; import org.slf4j.Logger; impo ...

  9. iomanip.h

    http://baike.baidu.com/link?url=zuNLgcUVylhUYYefyV13F38NChIMx8nnCEWV5zkkTQMrrSdKPxUERZuydSHtp6sXukWv ...

  10. POJ 3666 Making the Grade (DP)

    题意:输入N, 然后输入N个数,求最小的改动这些数使之成非严格递增即可,要是非严格递减,反过来再求一下就可以了. 析:并不会做,知道是DP,但就是不会,菜....d[i][j]表示前 i 个数中,最大 ...