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.
- Right-click on your project in the Solution Explorer.
- Click Properties at the bottom of the drop-down menu.
- At the top left of the Properties Pages,
select All Configurations from the drop-down menu. - Open the C/C++ tree and select Precompiled Headers
- Precompiled Header: Select Use (/Yu)
- Fill in the Precompiled Header File field. Standard is stdafx.h
Click Okay
If you do not have stdafx.h in your Header Files put it there. Edit
it to #include all the headers you want precompiled.- Put a file named stdafx.cpp into your project. Put #include "stdafx.h"
at the top of it, and nothing else. - Right-click on stdafx.cpp in Solution Explorer. Select Properties
and All configurations again as in step 4 ... - ... but this time select Precompiled Header Create (/Yc). This will only
bind to the one file stdafx.cpp. - Put #include "stdafx.h" at the very top of all your source files.
Lucky 13. Cross your fingers and hit Build.
Compile Error: Cannot open precompiled header.pch -- No such file or directory
There are 2 options to solve this:
Rebuild the full project. This should (re)create the precompiled header (or select
Build/Clean Solution
first).Turn off precompiled headers.
Project settings / C/C++ / Precompiled headers / Not Using Precompiled Headers
.
Trying to introduce Unit Testing to a project, but .pch file missing
The problem was that the project had been renamed at an earlier date.
Searching the Build Settings for oldname and updating them all to newname means that it's now looking for the files in the correct places.
xcode 6 pch.file not found
i solved it - in targets delete xctest target and it compiled
How to fix PCH error?
This is often a caching problem. Usually it can be resolved by holding down the Option key and choosing Product > Clean Build Folder...
Xcode .pch error while compiling. clang file not found
This can occur (not your fault) when the Xcode project file database gets messed up such that the referenced file does not appear in the navigation area but is still somehow included in one of the various list of files used for the build phases.
To see if this is the case:
- In the Finder, right click on the project file and select 'Show Package Contents'
- Right click on the file 'project.pbxproj' and 'Open With->TextEdit.app'
- In TextEdit menu: 'Edit->Find->Find...' [or command-F] then enter '.pch'
- Look at all occurrences of '.pch' [command -G to move to next one]
If you find occurrences of '../firstFoo-Prefix.pch' then your project file is corrupted. Looking at the context of the occurrence(s) will give you some indication of which area the corruption occurs in (e.g. build phase compile files list).
Sometimes just deleting those references (after having backed-up the project file of course) has worked for us but other times it just makes matters worse. The safest recovery is to create a new project file and copy over all the folder groups and settings manually. Your source code is all fine, it's just the cross-references and build settings that need reworking.
Related Topics
Creating, Opening and Printing a Word File from C++
When Is #Include <New> Library Required in C++
Is "Inline" Implicit in C++ Member Functions Defined in Class Definition
Header File Included Only Once in Entire Program
What Is an Iterator in General
Xcode with Boost:Linker(Id) Warning About Visibility Settings
How to Automatically Avoiding Stepping into Certain Functions in Visual Studio
Boost::Asio - How to Interrupt a Blocked Tcp Server Thread
For Purposes of Ordering, Is Atomic Read-Modify-Write One Operation or Two
How to Avoid Static Member Function When Using Gsl with C++
Must New Always Be Followed by Delete
What Is a Reference-To-Pointer
Why Is #Define Bad and What Is the Proper Substitute
Forwarding All Constructors in C++0X