#### Archived

This topic is now archived and is closed to further replies.

# The MFC error

This topic is 4970 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

Hey, I''m changing from Win32 and going to learning a littel MFC so I''m well rounded. I''m facing a problem. It gives me this error:
--------------------Configuration: MFC lesson01 - Win32 Debug--------------------
Compiling...
MFC lesson01.cpp
c:\projects for vc++\mfc lesson01\mfc lesson01.cpp(4) : fatal error C1083: Cannot open precompiled header file: ''Debug/MFC lesson01.pch'': No such file or directory
Error executing cl.exe.

MFC lesson01.obj - 1 error(s), 0 warning(s)

can anyone tell me what this means? Thanks.

##### Share on other sites
I usually find deleting the debug folder and recompiling the project helps in these situations. I''m not sure what the technical reason behind the error is apart from the fact that something is probably corrupt in the current build.

##### Share on other sites
no it is still giving me the error when I try to compile it

##### Share on other sites
IT points to this line saying it''s the error
#include "stdafx.h"
why? I''m can''t see why microsfot put somthing there that creates an error. I havn''t even coded anythign yet. I let the MFC App Wizard create the basics

##### Share on other sites
If your project is using precompiled headers then it will use a particular header to generate the pre-compiled ones. It will expect this header to appear in every cpp file which has precompiled headers set. It must be the first header. Do not pass go.

##### Share on other sites
I really don't see the point of precompiled headers. I think you could just do better with a central include file ('main.h') and have a seperate source file for your global declarations ('vars.cpp' or 'defs.cpp').

To fix this problem, you will probably want to change your project options. Assuming you are using VC++ 6:

1. Open Project->Settings...
2. Click C/C++ tab
3. Click 'Category' combo box and select 'Precompiled headers'
4. Either click 'Use precompiled header file' or 'Automatic use of precompiled headers' and enter 'stdafx.h' (or maybe 'MFC lesson01.h') in the 'Through header' edit box.

Hope this helps.

-- Fyhuang, president, Altitude Technologies

Altitude Technologies: http://www.hytetech.com/altitude
Altitude Forums: http://s8.invisionfree.com/Altitude_Forums/

[edited by - fyhuang on June 9, 2004 8:44:17 PM]

##### Share on other sites
quote:
Original post by fyhuang
I really don''t see the point of precompiled headers.

For example, I use the boost libraries and the STL. These are templated, header only libraries. In boost it can take ages to compile as there are lots of clever things going on. Same with STL.

If you put them in your pre-compiled header it can MASSIVELY cut down on compile times. Really, truely. I don''t have numbers but it dropped from between 30-60 seconds down to a few seconds. Big difference if you''re doing iterative development and testing.