Add a custom pre-compilation header in a VC Empty Project (or about: Unable to open the pre-compilation header file: "Debug/xxx. PCH": no such file or directory solution)

Source: Internet
Author: User

From: http://www.cppblog.com/silekey/articles/87108.html

Note: Many compilation and link parameters are added to the Framework generated by default by MFC. If we want to customize our own framework, unfamiliar compilation parameters will cause many problems.

Keyword: VC Empty Project custom pre-compilation header. PCHThe pre-compiled header file cannot be opened: "Debug/Xxx. PCH ": no such file or directory

 

Here is a concept to be explained first:

1> at least one CPP in the code is used to create the pre-editing Authorization header.

2> Other CPP statements are precompiled with the precompiled header.

3> the pre-compilation header is a technology that prevents repeated compilation to speed up compilation.

4> most people (in fact, I am the only one, and others have never asked) have encountered this problem because they do not know every one. CPP files can and must be set with precompiled header parameters respectively !!!!

 

Okay. Let's just say nothing. Create a blank project first.

Add the CPP file and write it to main;

Add config. cpp and config. h for our pre-compilation header, and set in the project:

Note: The compilation is based on. cpp. Therefore, the precompiled header file must be dependent on a. cpp file before it can be compiled.

Then we compile and get the following two errors:

Fatal error c1010: unexpected end of the file when searching for the pre-compiled header.

Fatal error c1083: Unable to open the pre-compiled header file: "Debug \ tmain. PCH": no such file or directory

Translate the corresponding errors as follows:

Fatal error c1010: Boss, you said this. cpp file needs to be precompiled with the header. If it is not found, it will strike!

Fatal error c1083: Pre-compiled headers are all used. Which of the following statements creates the pre-compiled CPP file!

Sorry, I cannot change it for you.

 

The first error is that config. H is not added to the. cpp file.

The second error is that the CPP file without the pre-compilation header is not created, and the compiler cannot. The solution is to set the file:

 

Actually, I understand that this is super simple, but I am so bored before I know it. I don't know how long it took for me to solve this small problem. previously, it was set to not use this header. later I found this thing really good!

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.