Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Compile Error: Cannot open precompiled header.pch -- No such file or directory

I have recently purchased the text "Programming: Principles and Practice Using C++" by Bjarne Stroustrup and have been following it through. I am currently stuck on an early project, where I need to output some strings of text. Using Visual Studio Community 2015 update 1, on a Windows 10 Lenovo Yoga 2 Pro laptop, I have attempted to compile the project but have ran into an error detailed:

"Cannot open precompiled header file: Debug\Finding the Upstairs Bathroom.pch': No such file or directory". The name of the project is aptly named "Finding the Upstairs Bathroom.cpp". Here is the code:

// I have the headers "stdafx.h" as well as this specific header lib 
// Bjarne Stroustrup created and which I had linked
// called "../../std_lib_facilities.h", which contains the standard C++ lib functions.

(#) define _SILENCE_STDEXT_HASH_DEPRECATION_WARNINGS 1

int main()`// Main function`

{  
    cout << "Take the key out of your right pants pocket\n"; // Outputs string of text

    cout << "Unlock the front door of the house\n";

    cout << "Open the front door and step inside\n";

    cout << "Lock the front door using the key\n";

    cout << "Move up the stairs, taking them two at a time\n";

    cout << "Walk to the second door on the left and face it directly\n";

    cout << "Using the door handle, turn it and push the door forward\n";

    cout << "Enter the bathroom while leaving the door open behind you\n";

    keep_window_open();

    return 0;
}

I would be grateful if someone is able to figure out how to fix my error.

like image 681
Rudis Avatar asked Jan 14 '16 20:01

Rudis


2 Answers

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.

like image 70
Danny_ds Avatar answered Sep 17 '22 22:09

Danny_ds


Appart from the options presented by Danny_ds, you can:

  • Create precompiled headers: Project settings / C/C++ / Precompiled Headers

    Precompiled Headers: Create (/Yc)

    Create VS precompiled headers

  • Disable precompiled headers. Project settings / C/C++ / Precompiled Headers

    Precompiled Headers: Not Using Precompiled Headers

I had the problem when I first had to create the precompiled header.

like image 32
lmiguelmh Avatar answered Sep 18 '22 22:09

lmiguelmh