Friday, November 16, 2007

Don't share intermediate directories

OK, I've been bitten by this issue twice.

Take care when setting the intermediate directory (Project->Properties->Configuration Properties->General->Intermediate Directory) for Visual C++ projects.

If you have multiple projects that use the same intermediate directory you are likely to run into problems. 

Specifically, if you're using a multi-core machine to build projects that share an intermediate directory and those projects happen to build in parallel the second project will fail when it tries to delete the files in the intermediate directory.

One way to ensure this never happens is to set the intermediate directory to $(ProjectName)_$(ConfigurationName).

This is particularly nasty because if you create two vcproj's in the same directory this will happen with the default parameters.