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?
-
1I've added the `[visual-c++]` tag since I think the `/MP` flag is specific to the VC++ compiler. – James McNellis Apr 23 '10 at 00:44
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.

- 963
- 10
- 18
-
1The issue with `#import` is well explained in [C2813](http://msdn.microsoft.com/en-us/library/bb384890%28v=vs.90%29.aspx), which is the error you'll get when using the /MP switch in VS2008 and above. (Note: VS2005 also has the undocumented /MP switch, but it hasn't got this error.) – Martin Ba Feb 12 '14 at 13:41
-
1The rest of the incompatible features are described [here](https://msdn.microsoft.com/en-us/library/bb385193.aspx) – gallo Oct 28 '16 at 21:53
-
@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). – codeling Aug 08 '17 at 09:53
-
-
@ZAB must have been the case, or the environment variable wasn't stored properly yet (I'm using third party software for that). tried again without space and it works. thanks for getting back to me! – codeling Aug 11 '17 at 07:35
-
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
false
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.

- 348,265
- 75
- 913
- 977
-
From this http://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. – dwj Apr 23 '10 at 00:42
-
@dwj: You would, yes. Note also what I just added about Visual C++ 2010. – James McNellis Apr 23 '10 at 00: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. – dwj Apr 23 '10 at 00:52
-
@dwj: Sadly, no, and it doesn't sound like that will change too soon: http://connect.microsoft.com/VisualStudio/feedback/details/467801/enable-mp-by-default-in-c-compiler – James McNellis Apr 23 '10 at 01:04