I'm using Visual Studio 2008 on my main build system. I've been playing with Visual Studio 2010 on another one. It appears that the tool still only wants to use one core when compiling unless you specify the /MP switch in the compiler switches (see How do I turn on multi-CPU/Core C++ compiles in the Visual Studio IDE (2008)?). I have to do this for every project. Is there a way to make VS always do this?
2 Answers
Create environment variable "CL" and set it to "/MP". Microsofts compiler cl.exe always prepend command line flags with this variable.
Some compiler features and options like #import aren't compatible with /MP flag. You will need to add /MP1 to projects used #import in a code. This will disable /MP for those projects.
-
1
-
1
-
@ZAB I'm pretty sure (but would like your opinion/experience) that the value needs to be " /MP". Notice the space - without it, the environment variable didn't have the desired effect (still only one core was used).– codelingCommented Aug 8, 2017 at 9:53
-
@codeling have you reopened studio after environment variable change?– ZABCommented Aug 10, 2017 at 13:18
-
1Minor qualification: it's not necessary to use /MP1 for an entire project if just a couple of files use #import. In project files (certainly for Visual Studio 2017) one can turn it off for selected source files using <ClCompile Include="foo.cpp"> <MultiProcessorCompilation>false</MultiProcessorCompilation> </ClCompile>– egyikCommented Jan 25, 2019 at 9:20
Your can create a property sheet that all of your projects include, and set the /MP
flag in that property sheet.
In Visual Studio 2010, you could put it in the Microsoft.Cpp.Win32.user property sheet, which is included in new projects by default (it has the old Visual C++ directories and other default settings defined in it). I don't know that modifying the default property sheet is really a good idea, but it's certainly an option.
-
From this msdn.microsoft.com/en-us/library/3z7t21ew%28v=VS.90%29.aspx it looks like I still have to go into each project and tell it to inherit the property sheet.– dwjCommented Apr 23, 2010 at 0:42
-
@dwj: You would, yes. Note also what I just added about Visual C++ 2010. Commented Apr 23, 2010 at 0:43
-
Modifying included templates always makes me nervous; I forget to do it if I reinstall! Thanks for the pointers; I was really hoping MS either made /MP the default or allowed it to always be turned on for a given developer/environment.– dwjCommented Apr 23, 2010 at 0:52
-
@dwj: Sadly, no, and it doesn't sound like that will change too soon: connect.microsoft.com/VisualStudio/feedback/details/467801/… Commented Apr 23, 2010 at 1:04
[visual-c++]
tag since I think the/MP
flag is specific to the VC++ compiler.