Parallel builds in Visual C++ 2005
(via Herb Sutter's blog)
If you haven't upgraded to Visual Studio 2008 yet, or like me, discovered that the mighty Boost doesn't build with it yet, then you might be interested to know that one of its most useful new features for C++ developers is available, undocumented, in '2005.
If you've got SMP (which is pretty likely these days), you probably know that Visual C++ 2005 already offers parallel project builds, and that they're useless if your solution contains a single monolithic project, or a bunch of interdependent projects.
However, VC 2005 actually has the ability to parallelise compiles at the source file level, too. In your project's properties, go to C/C++ -> Command Line, and in the Additional options box, add "/MP". Now it'll build as many compilation units (i.e. .cpp files) in parallel as you have CPUs. I did a "dual core on a budget" upgrade last week, and /MP has actually halved my build times. Now I can stop rueing my liberal usage of slow-building C++ templates!
Caveat: The compiler output can look a little mixed up, but you get used to it.
Don't let this revelation stop you upgrading to 2008, but if you're stuck with 2005 for reasons financial, technical, or political then /MP might be the most productive three characters you could type.
Post a comment
The complete syntax of the /MP compilerswitch is "/MP[nProcesses]". It is a good idea to create twice as much processes than installed CPUs.
Powered by clunkyblog release 3.10. Generated in 10ms.