Click here to Skip to main content
14,872,753 members
Articles / Programming Languages / C++
Tip/Trick
Posted 13 Feb 2010

Tagged as

Stats

38.2K views
2 bookmarked

*.pch file missing!

Rate me:
Please Sign up or sign in to vote.
1.00/5 (1 vote)
15 Feb 2010CPOL
Sometimes, Visual c++ users see a pretty confusing error message when they compile or build their projects. the error message says :fatal error C1083: Cannot open precompiled header file: 'filename.pch': No such file or directorymy solution was :In VS, go to Project->Options, set the...
Sometimes, Visual c++ users see a pretty confusing error message when they compile or build their projects. the error message says :

MSIL
fatal error C1083: Cannot open precompiled header file: 'filename.pch': No such file or directory


my solution was :

MSIL
In VS, go to Project->Options, set the Configuration Combobox in top to 'All Configurations', and then from left pan, choose 'C/C++->Precompiled Haeders' and set 'Create/Use Precompiled headers' option to value : 'Create Precompiled headers (/Yc)'.


which turned out not to be an accurate solution (Read the Messages below).

well, here is the solution :


1) Right click on the PROJECT (in Solution Explorer) | Properties | C/C++ | Pre-compiled Headers... here you set to ** /Yu **
2) Right click on STDAFX.CPP (in Solution Explorer) | Properties | C/C++ | Pre-compiled Headers... here you set to ** /Yc **

its done.

all credits for this tip goes to :SledgeHammer01

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

Share

About the Author

The Zetta
Iran (Islamic Republic of) Iran (Islamic Republic of)
No Biography provided

Comments and Discussions

 
QuestionWorked For Me! Thank You !!!!!!!!!!!!!!!!!+! Pin
Member 912601929-Mar-17 14:26
MemberMember 912601929-Mar-17 14:26 
GeneralMy vote of 1 Pin
SledgeHammer0114-Feb-10 8:06
MemberSledgeHammer0114-Feb-10 8:06 
GeneralRe: My vote of 1 [modified] Pin
The Zetta14-Feb-10 9:39
MemberThe Zetta14-Feb-10 9:39 
GeneralRe: My vote of 1 Pin
SledgeHammer0114-Feb-10 10:57
MemberSledgeHammer0114-Feb-10 10:57 
GeneralRe: My vote of 1 Pin
The Zetta14-Feb-10 21:24
MemberThe Zetta14-Feb-10 21:24 
GeneralRe: My vote of 1 Pin
SledgeHammer0115-Feb-10 7:13
MemberSledgeHammer0115-Feb-10 7:13 
No, *YOU* are misunderstanding.

1) Fine, if you want to be technical. /Yc and /Yu are the options. There is no /Ynothing option. You have 3 choices with 2 flags.

2) By "GLOBAL", I meant GLOBAL *PROJECT* settings. You can set /Yc and /Yu PER PROJECT, but you can also override and set PER C++ FILE. ** This is what you don't seem to understand **

3) Yes, if you specify /Yc and /Yu together, /Yc will be done and /Yu will be ignored.

BUT YOU ARE SETTING THAT OPTION FOR EVERY SINGLE C++ FILE. THAT IS WRONG.

/Yc is NOT CREATE AND USE. IT IS ***CREATE***. YOU ALSO DON'T SEEM TO UNDERSTAND THAT.

/Yu is ***USE***. This option DOES NOT CREATE the PCH. YOU ALSO DON'T SEEM TO UNDERSTAND THAT.

THAT is why you get the error when you delete the PCH.

NO, NO, NO, NO, NO, FOR THE LOVE OF GOD NO... Changing project options every day?? NO NO NO. AND AGAIN NO.

If your PCH settings are done correctly, you NEVER need to change options.

THERE IS SOMETHING VERY WRONG WITH YOU IF YOU THINK YOU NEED TO CHANGE THOSE OPTIONS to regen the PCH.


Once again... the CORRECT WAY to set up your project:

1) set the project to /Yu so every file USES the PCH
2) change the settings for stdafx.cpp to /Yc so it GENERATES the PCH

You will never have to change the settings again.

Face it... your tip is WRONG and you do not understand these options.
That is why I gave you a 1.
GeneralRe: My vote of 1 Pin
The Zetta15-Feb-10 8:34
MemberThe Zetta15-Feb-10 8:34 
GeneralRe: My vote of 1 Pin
SledgeHammer0115-Feb-10 8:40
MemberSledgeHammer0115-Feb-10 8:40 
GeneralRe: My vote of 1 Pin
The Zetta15-Feb-10 21:31
MemberThe Zetta15-Feb-10 21:31 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.