如何在 QTCreator 中使用 mingw 在多个内核上进行编译 [英] How to compile on multiple cores using mingw inside QTCreator
问题描述
我的 Windows 桌面上有一个四核 i7 CPU.我试图让 mingw32-make 使用尽可能多的核心进行编译.我已将 -j8 添加到 Build Settings->Build Steps 下的Make Arguments"字段中.mingw32-make 似乎完全忽略了该选项,因为我没有从中获得任何速度提升.当我在任务管理器中查看 CPU 使用率时,它保持在 13% 并且我只看到一个 g++ 实例正在运行.
I have a quad-core i7 CPU on my windows desktop. I am trying to get mingw32-make to compile using as many core as possible. I have added -j8 into the "Make Arguments" fields under Build Settings->Build Steps. mingw32-make seems to completely ignore the option since I don't get any speed improvement out of that. When I view the CPU usage in task manager, it stays at 13% and I only see one instance of g++ running.
现在,使用 mingw 重建整个项目需要整整 3 分钟.使用 MSVC 重建它只需要 15 秒.
Right now, rebuilding the whole project using mingw takes 3 full minutes. Rebuilding it using MSVC takes only 15 seconds.
为了您的信息,我在项目设置中启用了预编译头选项.这也使 VC 的事情变得更快.但是我还没有看到使用 mingw 预编译头文件的好处.
For your information, I have enabled the precompiled header option in the project settings. That makes things a lot quicker with VC as well. But I am still yet to see the benefit of precompiled header with mingw.
如果您曾经使用 mingw 从 QTCreator 并行编译多个源文件,请分享您的意见.谢谢!
Please share your comments if you have ever got mingw to compile multiple source files in parallel from QTCreator. Thanks!
推荐答案
这是我所做的.
在 Qt Creator 的工具 -> 选项菜单中,在构建和运行"部分下有一个选项,上面写着使用 jom 而不是 nmake".我检查了那个框,但没有任何改变.因此,我转到了项目的构建设置,在构建步骤类别下有一个制作"项目.展开有关的详细信息,您将找到覆盖 mingw32-make.exe:"项.我在那里粘贴了C:\QtSDK\QtCreator\bin\jom.exe",突然间我正在构建多核.
In the Tools -> Options menu in Qt Creator, under the "Build and Run" section there's an option that says "Use jom instead of nmake". I checked that box, but nothing changed. So instead, I went to the project's build settings and under the build steps category there is a "Make" item. Expand the details on that and you'll find a "Override mingw32-make.exe:" item. I pasted "C:\QtSDK\QtCreator\bin\jom.exe" in there, and suddenly I was building with multiple cores.
在 Qt Creator 2.4.1 上为我工作.试试看.
Worked for me on Qt Creator 2.4.1. Give it a try.
这篇关于如何在 QTCreator 中使用 mingw 在多个内核上进行编译的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!