How can I do a parallel build in Visual Studio 2010?

Visual StudioVisual Studio-2010Visual C++Parallel Builds

Visual Studio Problem Overview


How can I get VS 2010 to run more than one C++ compile process at a time? I mean building object modules in parallel; I'm not interested in building more than one project at a time (I know about Tools > Options > Build and Run < Maximum number of parallel project builds, but that doesn't do what I want).

Basically, I'm looking for Visual Studio's equivalent of "make -jN".

Visual Studio Solutions


Solution 1 - Visual Studio

  1. Tools -> Options
  2. Projects and Solutions\VC++ Project Settings
  3. Maximum concurrent C++ compilations

Also, as Ross Smith said in the comments, you also need to turn on the "Multiprocessor compilation" option on the project:

  1. Project properties
  2. Configuration Properties > C/C++ > General
  3. Multi-Processor Compilation
  4. Profit!

Solution 2 - Visual Studio

There are two switches that must be set in order to make VS build using multithreading (both are project-specific):

  • project properties->C/C++->General->Multi-processor Compilation set to: Yes (/MP)
  • project properties->C/C++->Code Generation->Enable Minimal Rebuild set to: No (/Gm-)

Check also Your Tools->Options->Projects and Solutions->VC++ Project Settings->Maximum concurrent C++ compilations setting. Default value is 0 which enables VS to use as many concurret compilations as possible.

Solution 3 - Visual Studio

Necrolis' comment seems the correct solution.

/MP (Build with Multiple Processes)

> The /MP option causes the compiler to create one or more copies of > itself, each in a separate process. These copies simultaneously > compile the source files. Consequently, the total time to build the > source files can be significantly reduced.

Note that you can set it at project level (and thus it will apply to all files in it) as well as to the individual files, useful for instance if you need to use #import.

In particular, /MP is usually not compatible with precompiled headers, or sources using #import; in this case, you can still set /MP flag on the project, and then clear it on the single files (usually, stdafx.cpp, and any file using #import).

Solution 4 - Visual Studio

jom is the tool you are looking for.

From the wiki at: http://qt-project.org/wiki/jom

> jom is a clone of nmake to support the execution of multiple > independent commands in parallel. It basically adds the -j command > line switch similar to GNU make.

While most of the documentation is aimed at Qt developers trying to speed up Qt library builds on windows, jom should work perfectly well in non Qt projects too, as long as you have an nmake compatible makefile.

The wiki page has binaries you can download, and you call jom as you would nmake.

Solution 5 - Visual Studio

Here is what I did

  1. Go to Tools->Options than under "Project And Solutions"->"Build And Run" for me it had the number of cores. Although at first i thought this was all i needed to do but it isnt

  2. Right click your project and select properties. Under "configuration properties"->"C/C++"->"Command Line" enter /MP4 where 4 is the number of cores you have. You'll get a warning about flags not being compatible so we have another step

  3. Go to Under "configuration properties"->"C/C++"->"Code Generation" there is "Enable minimum rebuild". Change that to no.

Rebuild and you should see multiple CL processes in your task manager.

Solution 6 - Visual Studio

I see! Your requirement is building single project in parallel threads.

I find Shark compiler Control plugin very useful

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionRoss SmithView Question on Stackoverflow
Solution 1 - Visual StudioBilly ONealView Answer on Stackoverflow
Solution 2 - Visual StudiojskierbiView Answer on Stackoverflow
Solution 3 - Visual StudiorobView Answer on Stackoverflow
Solution 4 - Visual StudioRian SandersonView Answer on Stackoverflow
Solution 5 - Visual Studiouser34537View Answer on Stackoverflow
Solution 6 - Visual StudioDigital_RealityView Answer on Stackoverflow