Question

I have a C++ console project that I included a precompiled header in the setup. I accidentally deleted the file from my project and now I can't compile because I get error C1083: Cannot open precompiled header file: 'Debug\Project.pch': No such file or directory. Do I have to re-create the project and import all the code into it? I tried re-creating a file named "stdafx.cpp" that contains only #include "stdafx.h", but that does not work. How do I fix this?

Was it helpful?

Solution

Right-click stdafx.cpp in Solution Explorer and choose Properties. Under C/C++ > Precompiled Headers, set "Precompiled Header" to "Create (/Yc)". You may also need to set "Precompiled Header File" to "stdafx.h" and "Precompiled Header Output File" to whatever makes sense ("$(IntDir)$(TargetName).pch" in most cases).

Unless there are other issues too, that should do it.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top