如何利用 nmake 的所有核心?
我刚买了一台新的四核计算机,注意到 nmake 仅使用 1 个进程。
我曾经使用带有开关 -j4 的 make 来启动 4 个进程。 nmake 的等价物是什么?
[编辑] 根据下面的信息,我已经能够向我的 qmake 项目文件添加一个命令:
QMAKE_CXXFLAGS += /MP
这有效地为我完成了它。 非常感谢。
I just got a new quad core computer and noticed that nmake is only using 1 process.
I used to use make which had the switch -j4 for launching 4 processes. What is the nmake equivalent?
[edit]
Based on the information below I have been able to add a command to my qmake project file:
QMAKE_CXXFLAGS += /MP
Which effectively did it for me. Many thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(8)
另一种通用的、与 Qt 无关的方式告诉 nmake 使用所有内核,是将环境变量 CL 设置为 /MP:
将使用所有 CPU 核心。
Another generic, non-Qt-related way to tell
nmake
to use all the cores is to set environmental variableCL
to/MP
:will use all the CPU cores.
QT 有一个工具可以实现这一点:
http://download.qt.io/official_releases/jom/
他们还使用它Qt 创建者中的默认值。
QT has a tool for this:
http://download.qt.io/official_releases/jom/
They also use it per default in Qt creator.
根据 MSDN,< 没有这样的选项代码>nmake。
但是,您可以通过使用 VC++ 命令行编译器的
/MP
选项并同时传递多个文件,使编译器并行构建多个文件:但是请注意,大多数 Makefile 不会调用编译器像这样 - 他们通常为每个单独的源文件单独调用编译器,这将阻止
/MP
选项执行任何有用的操作。According to MSDN, there's no such option for
nmake
.You can however make the compiler build multiple files in parallel by using the
/MP
option with the VC++ command line compiler and passing multiple files at the same time:However note that most Makefiles don't call the compiler like this - they usual invoke the compiler separate for each individual source file, which would prevent the
/MP
option from doing anything useful.Incredibuild 声称能够在多核/多台机器上运行 nmake 构建。 我对此没有任何经验。
Incredibuild claims to be able to run nmake builds on multiple cores / multiple machines. I don't have any experience of it.
截至撰写本文时,CMake 2.8.1 RC1它已经准备好尝试,确实为 NMake 带来了新的生成器,称为 NMake Makefiles JOM 并生成具有 jom 特定设置的 NMake,这是 NMake 的替代品。 因此,它使用 NMake 提供了支持多处理的构建。
The CMake 2.8.1 RC1, as for the time of writing this it's ready to try, does bring new generator for NMake which is called NMake Makefiles JOM and it generates NMake with specific settings for jom, which is the drop in replacement of NMake. Thus, it gives multi-processing enabled building using NMake.
快速谷歌搜索给出: http://msdn.microsoft.com/en-us/库/bb385193.aspx
Quick googling gives: http://msdn.microsoft.com/en-us/library/bb385193.aspx
这对于普通的 makefile 不起作用,但 Visual Studio 2005 中有一项设置可以让您同时生成多个 .vcproj 文件(前提是一个文件不依赖于另一个文件)。 工具-> 选项-> 项目和解决方案 -> 构建并运行 -> X 并行项目构建的最大数量。
This doesn't work for normal makefiles, but there is a setting in Visual Studio 2005 that lets you build more than one .vcproj file at the same time (provided one isn't dependent on the other). Tools -> Options -> Projects and Solutions -> Build and Run -> X maximum number of parallel project builds.
它并不完全相同,但如果您使用
cmake
,您可以导出解决方案(例如使用生成器“Visual Studio 14 2015”而不是“NMake Makefiles”)。在这种情况下,可以使用
msbuild
工具构建导出的解决方案,该工具允许您使用/maxcpucount
命令行开关并行化构建过程。It's not quite the same, but if you use
cmake
, you can export solution (e.g. using generator "Visual Studio 14 2015" instead of "NMake Makefiles").In this case it's possible to build exported solution using
msbuild
tool which allows you to parallelize building process with/maxcpucount
command line switch.