Search code examples
visual-c++-2010

Visual C++ 2010 rebuilds all files in the project even though only one .CPP file was changed


I have VC++ 2010 solution that contains multiple projects - several DLL-s and one EXE

Whenever I change one .CPP source file (any file) in project for .EXE and build a solution all files in project for .EXE are recompiled.

If I change a single file in any project for DLL-s (.EXE depends on .DLL-s) only the file I changed is recompiled, DLL is relinked (as expected until this point) and then all files in project for .EXE are recompiled.

This project was recently ported from VC++ 2008 and under 2008 it didn't exhibit this behavior. That is under VC++ 2008 only changed files were recompiled and then .EXE was re-linked.

Does anyone know what the reason for this can be? Or is there a way to emit some kind of diagnostic output from C++ compiler that will indicate why it decided that particular .CPP file is not up to date and needs to be recompiled?


Solution

  • The reason was that project in question had incorrect settings for Precompiled Headers. It was set to "Create" at project level.

    I changed setting to "Use" at project level and "Create" for stdafx.cpp and it fixed the problem.