How to fix .pch file missing on build?

NOTE: Later versions of the IDE may use “pch” rather than “stdafx” in the default names for related files. It may be necessary to substitute pch for stdafx in the instructions below. I apologize. It’s not my fault.

  1. Right-click on your project in the Solution Explorer.
  2. Click Properties at the bottom of the drop-down menu.
  3. At the top left of the Properties Pages,
    select All Configurations from the drop-down menu.
  4. Open the C/C++ tree and select Precompiled Headers
  5. Precompiled Header: Select Use (/Yu)
  6. Fill in the Precompiled Header File field. Standard is stdafx.h
  7. Click Okay

  8. If you do not have stdafx.h in your Header Files put it there. Edit
    it to #include all the headers you want precompiled.

  9. Put a file named stdafx.cpp into your project. Put #include “stdafx.h”
    at the top of it, and nothing else.
  10. Right-click on stdafx.cpp in Solution Explorer. Select Properties
    and All configurations again as in step 4 …
  11. … but this time select Precompiled Header Create (/Yc). This will only
    bind to the one file stdafx.cpp.
  12. Put #include “stdafx.h” at the very top of all your source files.

Lucky 13. Cross your fingers and hit Build.

Leave a Comment