构建 Qt 应用程序的“共享构建”(exe 在外部查找 Qt dll 并且体积较小的构建)需要非常快(<5 分钟)
“静态构建”(针对构建的静态 Qt 应用程序的链接,以后不需要 dll)发布构建需要大约 30 分钟,调试构建需要 90 分钟。
这是完全不可避免的吗?
我相信它在链接阶段等待了很长时间。有什么办法可以加快速度吗?它是试图链接到每个可能的 Qt 库还是什么?
在QT
标志中,我只添加了core
、network
和gui
。链接应该不会花费一个多小时,为什么会这样?
我在虚拟机上的 Windows 7
上使用 QtCreator
和 MinGW
。
编辑:
看来跟添加调试符号有关。当我将调试符号添加到发布版本时,我也获得了 90 分钟的构建时间。
最佳答案
Building a "shared build" of a Qt app (a build where the exe looks for Qt dlls externally and is small in size) takes very quickly (<5 minutes)
A "static build" (links against built static Qt apps, doesn't require dlls later on) takes about 30 minutes for a release build and 90 minutes for a debug build.
Is this completely unavoidable?
一般来说,使用 VM 意味着使用更少的 CPU“头”。然后确保您的 VM 使用足够的 CPU 资源。 “静态”构建时间表明您构建的可能不仅仅是一个应用程序,而是静态的 Qt 框架本身。
另外,您是否有预构建的静态 Qt 可以反复使用?或者,您为“静态”重建它,请务必查看文章 Building Qt 5 from Git出:
Multicore building:
To speed up building when using nmake, the compiler can be instructed to use all available CPU cores in one of the following ways:
- Pass the option -MP to Qt's configure
- Set the environment variable CL (specifying Visual Studio compiler options) to /MP (On the command line: set CL=/MP)
- Use the tool jom instead of nmake. (Using jom instead of nmake reduces compile time quite a bit)
如果它只是关于构建应用程序代码而不是 Qt 本身,只需注意您为 VM 分配的 CPU 磁头并选择 jom 与 nmake,只要它默认并行编译器执行即可。
关于c++ - Qt 静态构建在虚拟机(win7 32 位)上需要很长时间,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34878779/