Answered by:
Problem with "Precompiled header file". Need help !!!

Question
-
Dear,
I re-compile Ogre SDK (www.ogre3d.org), i meet a problem. There is an error like:
1>------ Rebuild All started: Project: OgreMain, Configuration: Release Win32 ------
1>Deleting intermediate and output files for project 'OgreMain', configuration 'Release|Win32'
1>Compiling...
1>cl : Command line warning D9035 : option 'Wp64' has been deprecated and will be removed in a future release
1>OgrePrecompiledHeaders.cpp
1>C:\Program Files\Microsoft Visual Studio 9.0\VC\include\vector(46) : error C2857: '#include' statement specified with the /YcOgreStableHeaders.h command-line option was not found in the source file
1>Build log was saved at "file://c:\Documents and Settings\Le Khanh Thanh\Desktop\KlinkCore\OgreMain\obj\Release\BuildLog.htm"
1>OgreMain - 1 error(s), 1 warning(s)
========== Rebuild All: 0 succeeded, 1 failed, 0 skipped ==========
Where: OgrePrecompiledHeader with declaration: #include "OgreStableHeaders.h"
My project settings in C/C++ tab is:
- Precompiled Headers:
+ Create/Use PCH through File: OgreStableHeaders.h
+ Precompiled Header File: $(InDir)\$(TargetName).pch
Then, i change my setting with:
- Precompiled Headers:
+ Create/Use PCH through File: OgreStableHeaders.h
+ Precompiled Header File:
Compiler still error: error C2857: '#include' statement specified with the /YcOgreStableHeaders.h command-line option was not found in the source file
Then i change my setting again, this time is:
- Precompiled Headers:
+ Create/Use PCH through File: OgreStableHeaders.h
+ Precompiled Header File: $(InDir)\$(TargetName).pch
Compiler still error: error C2857: '#include' statement specified with the /YcOgreStableHeaders.h command-line option was not found in the source file
Pls tell me what i was wrong ?
Thanks
thanhly'sMonday, May 25, 2009 11:30 AM
Answers
-
One of the .cpp files in your project must be compiled with the /Yc option to create the .pch file. Visual Studio project templates always use the stdafx.cpp file for that. That .cpp file must #include the header file which in turn #includes all the .h files that are to be pre-compiled. Project templates use the stdafx.h file for that.
Finally, every .cpp file that is compiled with /Yu to use the precompiled headers must #include the .h file as the very first #include. Get any of those details wrong and you'll be slapped with a compile error. Looks to me like the source file you selected for /Yc does not in fact #include "OgreStableHeaders.h".
Hans Passant.- Marked as answer by Rong-Chun Zhang Friday, May 29, 2009 9:54 AM
Monday, May 25, 2009 3:43 PM
All replies
-
One of the .cpp files in your project must be compiled with the /Yc option to create the .pch file. Visual Studio project templates always use the stdafx.cpp file for that. That .cpp file must #include the header file which in turn #includes all the .h files that are to be pre-compiled. Project templates use the stdafx.h file for that.
Finally, every .cpp file that is compiled with /Yu to use the precompiled headers must #include the .h file as the very first #include. Get any of those details wrong and you'll be slapped with a compile error. Looks to me like the source file you selected for /Yc does not in fact #include "OgreStableHeaders.h".
Hans Passant.- Marked as answer by Rong-Chun Zhang Friday, May 29, 2009 9:54 AM
Monday, May 25, 2009 3:43 PM -
One of the .cpp files in your project must be compiled with the /Yc option to create the .pch file. Visual Studio project templates always use the stdafx.cpp file for that. That .cpp file must #include the header file which in turn #includes all the .h files that are to be pre-compiled. Project templates use the stdafx.h file for that.
Thank you so much ! I have resolve my issue
Finally, every .cpp file that is compiled with /Yu to use the precompiled headers must #include the .h file as the very first #include. Get any of those details wrong and you'll be slapped with a compile error. Looks to me like the source file you selected for /Yc does not in fact #include "OgreStableHeaders.h".
Hans Passant.
thanhly'sTuesday, May 26, 2009 5:35 AM -
You simplified my life.Friday, August 30, 2019 12:23 PM