构建优化的Qt4 - “配置”标志及其含义 [英] Building optimized Qt4 - "./configure" flags and their meanings

查看:184
本文介绍了构建优化的Qt4 - “配置”标志及其含义的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我最近在Qt4兴趣的邮件列表中讨论了建立商业/专有应用程序是否合法,并将Qt4静态链接到它。虽然有一些未经证实的方法(通过向客户提供目标文件和Makefile等),但这听起来似乎并不像以前那样好的主意。



我的项目之一是使用LGPL许可的Qt4库,并将其作为单独的DLL / Dylibs / so发送给我的客户,在所有平台上使用简单的安装程序。虽然这样做非常好,但我想通过仅仅包括我需要的方式来减少Qt库大小来优化安装程序的大小,b)增加我的应用程序的启动/加载速度。



我很熟悉自己编译Qt,但Qt有很多标志和开关。



现在我是使用以下标记构建:

  ./ configure \ 
-fast \
-opensource \\ \\
-qt-sql-sqlite \
-nomake演示示例\
-silent \
-no-qt3support \
-no-gif \\ \\
-plugin-sql-mysql \
-release \
-no-xmlpatterns \
-no-multimedia

我不完全确定以下标志的影响/影响:




  • -no-stl

  • -no-javascript-jit

  • -no-nis

  • -separate-调试信息
  • -no-openvg

  • -no-mitshm



还有什么我可以做的,例如,通过为编译器提供优化开关,或者剥离未构建的Qt库中的未使用的函数使其更小(这将很容易使用静态构建)。我没有太多的经验。



哦,就像一个旁注,我编译的应用程序大小是大约600 kb(非剥离),当链接到Qt动态我尝试了它,发现它大约4 MB的大小当我链接静态;但是这样我就不用再包含40 MB的Qt库了。



所以,把上面的一切放在一个问题/请求中:



如果您在这个主题上比我更先进,那么您如何优化/部署自己的应用程序,并确保它们开始快速,只包含所需的内容? / p>

解决方案

有几件事我可以想到:




  • 使用良好的大小优化的编译器/链接器组合。例如,MSVC比MinGW好得多。所有使用MSVC构建的Qt版本DLL总共达到〜21 MB。用MinGW构建,总共在〜41 MB。顺便说一句,你真的需要运送所有的DLL吗?

  • 使用-ltcg(链接时代码生成)标志来优化对象文件。

  • 使用预处理程序标志来排除Qt功能的部分。例如:QT_NO_STL = -no-stl。

  • 尝试mmx / 3d now / sse2标志

  • 删除一些样式(-no-style - )


I recently followed a discussion on the Qt4-interest mailing list about whether it is legal or not to build a commercial/proprietary application and statically link Qt4 into it. While there are some non-proven ways of doing so (by providing object files and a Makefile, etc. to the customer), it doesn't sound like such a good idea afterall.

One of my projects is using the LGPL-licensed Qt4 libraries and I ship them as separate DLLs/Dylibs/so's to my customer, using a simple installer on all platforms. While this works pretty good so far, I'd like to optimize a) the size of the installer by reducing the Qt library size by just including what I need, b) increase the startup/loading speed of my application.

I'm familiar with compiling Qt myself, but Qt got a lot of flags and switches.

Right now I'm building with the following flags:

./configure \
  -fast \
  -opensource \
  -qt-sql-sqlite \
  -nomake demos examples \
  -silent \
  -no-qt3support \
  -no-gif \
  -plugin-sql-mysql \
  -release \
  -no-xmlpatterns \
  -no-multimedia

I'm not entirely sure which effect/impact the following flags have:

  • -no-stl
  • -no-javascript-jit
  • -no-nis
  • -separate-debug-info
  • -no-openvg
  • -no-mitshm

Is there anything else I can do, for instance, by providing optimization switches for the compiler, or "stripping" unused functions out of the built Qt library to make it smaller (which would be easy with static builds). I don't have much experience with that.

Oh, just as a side-note, my compiled application size is about 600 kb (non-stripped) when linking against Qt dynamically. I experimented with it and found it to be around 4 MB in size when I link statically; but that way I wouldn't have to include 40 MB of Qt libraries anymore.

So, to put everything above into a question/request:

If you are more advanced than me on this topic, how do you optimize/deploy your own applications and make sure they start fast and only contain what is needed?

解决方案

There are few things that I can think of:

  • use a compiler/linker combination that does good size optimizations. MSVC is much better at this than MinGW for instance. All the Qt release DLLs built with MSVC total at ~21 MB. Built with MinGW they total at ~41 MB. By the way, do you really need to ship all the DLLs?
  • use the -ltcg (Link-time code generation) flag to optimize across object files.
  • use preprocessor flags to exclude parts of the Qt functionality. e.g: QT_NO_STL = -no-stl.
  • try the mmx/3d now/sse2 flags
  • remove some of the styles (-no-style-)

这篇关于构建优化的Qt4 - “配置”标志及其含义的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆