快速 Qt C++在windows上编译
我有一个使用 Qt 框架的大型项目,并且正在尝试找到在 Windows 安装上编译它的最快方法。
在我家里的 Linux 机器上,我使用 3 年历史的 Linux Mint 设置,具有双核(该机器已有 3 年历史,未安装 Linux Mint),使用: make -j2 两个核心都被充分使用(ish )并且编译代码的速度相对较快,从干净构建开始大约需要 10 分钟。
然而,在我的工作 Windows PC(2.0 GHz Intel Core 2 Quad (XP))上,我似乎永远无法让编译速度像我的 Linux 机器一样快。该程序的开发人员文档建议使用 Visual Studio C++,使用从 cmake 生成的项目文件,但这似乎只使用一个核心,并且需要一个多小时才能编译,而在我的 Linux 安装上大约需要 10 分钟(从干净的构建)。
我尝试过使用 jom 但即使使用所有核心,它仍然需要大约一个半小时因为它似乎只在每个核心上使用少量的 cpu。
我的旧 Linux 机器构建速度很快,但四核却在下降,这对我来说是没有意义的。
I have a large project that uses the Qt framework and am trying to find the fastest way to compile it on my Windows install.
On my linux machine at home I use 3 year old Linux Mint setup with a dual core (the machine is 3 years old not Linux Mint install), using: make -j2 both cores are used full(ish) and compiles the code relatively quick, around 10 minutes from clean build.
However on my work Windows PC which is 2.0 GHz Intel Core 2 Quad (XP) I can never seem to get the compiles to be as fast as my Linux box. The developer docs for the program recommend using Visual Studio C++ using the project file generated from cmake but that only seems to use one core and takes well over a hour to compile vs about 10 minutes (from clean build) on my Linux install.
I have tred using jom but even when using all the cores it still takes around an hour and half because it only seems to use small amounts of cpu on each core.
Doesn't make sense to me that my old Linux machine builds quick but the quad core just slumps along.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(6)
多年来,以下内容有助于提高我们的 Windows C++ Qt 构建速度:
我们的 Windows 构建仍然比 Linux 慢,但我不能说这是一个公平的比较,因为我们共享的 Linux 构建盒比 Linux 构建要慢得多。比开发者电脑的规格更高。
(顺便说一句,如果您以前没有见过它们,那么值得一读 Jeff Atwood 关于开发人员 PC 的良好配置的说法:例如 程序员权利法案)
更新: 2012 年 10 月 25 日
如果您使用的是 Visual Studio 2008,并且使用 DLL 构建,我目前不建议迁移到 Visual Studio 2010:存在不必要的重新链接依赖项的问题绝对会降低开发人员生产力的项目,至少在具有 20 个左右 .vcxproj 文件的 .sln 中:
可能有一个解决方案 - 一旦我测试过它,我会稍后更新 - 请参阅不必要的重新链接使用 Visual Studio 2010 构建时的依赖项目,其中 CORCOR 说:
The following have helped the speed of our Windows C++ Qt builds, over the years:
Our Windows builds are still slower than Linux ones, but I can't say that's a fair comparison, as our shared Linux build box is a much higher spec than developer PCs.
(As an aside, if you haven't seen them before, it's worth reading what Jeff Atwood has to say about good configurations for developer PCs: e.g. the Programmer's Bill of Rights)
Update: 25/10/2012
If you are on Visual Studio 2008, with DLL builds, I do not currently recommend moving to Visual Studio 2010: there is an issue with unnecessary re-linking of dependent projects that absolutely kills developer productivity, at least in a .sln with 20 or so .vcxproj files:
There may be a solution to this - I'll update later, once I've tested it - see Unnecessary relinks of dependent projects when building with Visual Studio 2010 where CORCOR said:
这可能是一种解决方法,但我们使用 Incredibuild,它将构建分布在多台机器上,效果非常好。将我们的构建时间从 40 分钟缩短到 10 分钟。 (我们连接了 6 台开发人员 PC 来分担工作量)
This might be a bit of a workaround, but we use Incredibuild, which distributes the build across multiple machines, which works really well. Cuts down our build times from 40 to 10 minutes. (we have 6 developer PCs hooked up to share the workload)
Visual Studio 可以并行编译多个项目,但每个项目都是按顺序编译的。
因此,如果您编译包含 2 个项目的解决方案,则将并行启动两个进程,但如果您只有一个项目,则只会启动一个进程,并且它将按顺序编译您的源代码。
如果您使用 MingW,您可以按照以下线程操作: http:// www.mail-archive.com/[email protected]/msg00156.html
在那里你会找到解决方案(安装 MSys 并在启动 make 时指定参数 -j 以指定数量并行作业)。
一个更简单的解决方案在这里: http://developer.qt.nokia.com/forums /viewthread/855/
(在 QtCreator Tools->Options 中指定 Jom 作为构建工具而不是 NMake)
Visual Studio can compile several projects in parallel, but each single project is compiled sequentially.
So if you compile a solution with 2 projects then two processes will be launched in parallel, but if you have just one project then just one process will start and it will compile your source sequentially.
If you use MingW, you can follow this thread: http://www.mail-archive.com/[email protected]/msg00156.html
There you will find the solution (install MSys and specify the parameter -j when you launch make in order to specify the number of parallel jobs).
An even easier solution is here: http://developer.qt.nokia.com/forums/viewthread/855/
(in QtCreator Tools->Options specify Jom as build tool instead of NMake)
我也有同样的问题。我们的计算机上正在运行一个软件,该软件试图确定与 Windows 7 的兼容性。该软件会将软件的每次启动记录到数据库中,从而稍微减慢了新进程的启动速度。由于编译器为每个文件启动一个新进程,这显着减慢了整个编译运行的速度。
I had the same problem. On our machines was a software running that tried to determine the compatibility with Windows 7. This software was logging every start of a software to a database and thereby slowed down the startup of new processes a bit. Since the compiler starts a new process for every file this significantly slowed down the whole compile run.
在 Visual Studio 中,您是否转到:
项目 ->属性-> C++ 并将“多处理器编译”改为“是”?这对我打开多核起到了作用,实际上应该可以大大加快速度。
In Visual Studio did you go to:
Project -> Properties -> C++ and turned "Multiprocessor Compilation" to Yes ? That did the Trick for me turning on Multicore, which should speed it up actually quite much.
我认为最好的方法是将您的项目拆分为多个项目,每个项目都是静态库项目,通过容器项目(通常是 MainWindow 类)将它们连接在一起。因此,第一次编译需要一段时间,然后就会很短(取决于您的修改)。
I think is best way by splitting your project into multi-projects each project is Static library project join them together by container project which is usually MainWindow class. Thus compiling duration will takes a while for first time then it will be short (depending on your modifications).