C++ 我如何将所有内核用于 nmake?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/601970/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How do I utilise all the cores for nmake?
提问by Phil Hannent
I just got a new quad core computer and noticed that nmake is only using 1 process.
我刚买了一台新的四核计算机,注意到 nmake 只使用了 1 个进程。
I used to use make which had the switch -j4 for launching 4 processes. What is the nmake equivalent?
我曾经使用带有开关 -j4 的 make 来启动 4 个进程。什么是 nmake 等价物?
[edit] Based on the information below I have been able to add a command to my qmake project file:
[编辑] 根据下面的信息,我已经能够在我的 qmake 项目文件中添加一个命令:
QMAKE_CXXFLAGS += /MP
QMAKE_CXXFLAGS += /MP
Which effectively did it for me. Many thanks.
这对我来说有效地做到了。非常感谢。
采纳答案by Alnitak
According to MSDN, there's no such option for nmake
.
根据MSDN 的说法,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:
但是,您可以通过使用/MP
VC++ 命令行编译器的选项并同时传递多个文件,使编译器并行构建多个文件:
> cl /MP a.cpp b.cpp c.cpp
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.
但是请注意,大多数 Makefile 不会像这样调用编译器——它们通常为每个单独的源文件单独调用编译器,这会阻止该/MP
选项做任何有用的事情。
回答by Violet Giraffe
Another generic, non-Qt-related way to tell nmake
to use all the cores is to set environmental variable CL
to /MP
:
另一种通用的、非 Qt 相关的告诉nmake
使用所有内核的方法是将环境变量设置CL
为/MP
:
set CL=/MP
nmake
will use all the CPU cores.
将使用所有 CPU 内核。
回答by Tolik Odukha
QT has a tool for this: http://download.qt.io/official_releases/jom/
QT 有一个工具:http: //download.qt.io/official_releases/jom/
They also use it per default in Qt creator.
他们还在 Qt Creator 中默认使用它。
回答by Martin Beckett
Incredibuildclaims to be able to run nmake builds on multiple cores / multiple machines. I don't have any experience of it.
Incredibuild声称能够在多个内核/多台机器上运行 nmake 构建。我没有任何经验。
回答by mloskot
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 JOMand 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.
该CMake的2.8.1 RC1,为写这篇的时候它已经准备好尝试,并带来NMAKE被称为新的发电机NMAKE Makefile文件JOM,它与JOM特定的设置,这是在更换NMAKE的下降产生NMAKE。因此,它使用 NMake 提供了支持多处理的构建。
回答by Marcin Gil
Quick googling gives: http://msdn.microsoft.com/en-us/library/bb385193.aspx
快速谷歌搜索给出:http: //msdn.microsoft.com/en-us/library/bb385193.aspx
回答by teeks99
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 -> Xmaximum number of parallel project builds.
这不适用于普通的 makefile,但 Visual Studio 2005 中有一项设置可以让您同时构建多个 .vcproj 文件(前提是一个文件不依赖于另一个文件)。工具 -> 选项 -> 项目和解决方案 -> 构建和运行 -> X最大并行项目构建数。