Debug vs Release mode - Cannot open include file: 'stdafx.h'

Posted on 2007-07-19
Last Modified: 2013-12-14
I have a fairly complex application which compiles fine in Debug mode (in Visual Studio .NET) but when I switch to Release mode I get the error:
fatal error C1083: Cannot open include file: 'stdafx.h': No such file or directory

The #include "stdafx.h" that this error refers to is from a file that was developed outside my project (ie. I added the .cpp and .h file, but not its corresponding stdafx.h - because I have my own.)

I don't understand why it would compile in Debug but not in Release.
Question by:joannabanana
    LVL 86

    Expert Comment

    Under your project settings, check whether your Debug and Release configurations are different in "Additional Include Directories" and make sure that these entries are the same (if applicable).

    Author Comment

    Yup I checked that, they're exactly the same :(
    LVL 86

    Accepted Solution

    Can you check with FileMon ( where the compiler is looking for that file in both cases?
    LVL 8

    Expert Comment

    Is it possible that someone disabled "Precompiled headers" in debug mode?, but not in "Release" mode?

    Author Comment

    All the settings for the project seem to be the same for Debug and Release.

    I have now noticed, however, that I only get the error if I try to "Build" the solution but if I click "Start" (debugging), it asks me if I want to build the solution (as it is not up to date), I click Yes, and it builds and runs ok.
    Can anyone explain to me why this is so? I am fairly new to this and am getting a serious "crash course" (literally! lol).

    Featured Post

    How to run any project with ease

    Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
    - Combine task lists, docs, spreadsheets, and chat in one
    - View and edit from mobile/offline
    - Cut down on emails

    Join & Write a Comment

    Welcome my friends to the second instalment and follow-up to our Minify and Concatenate Your Scripts and Stylesheets (…
    Today I had a very interesting conundrum that had to get solved quickly. Needless to say, it wasn't resolved quickly because when we needed it we were very rushed, but as soon as the conference call was over and I took a step back I saw the correct …
    The viewer will learn how to use and create new code templates in NetBeans IDE 8.0 for Windows.
    The goal of the tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…

    746 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    16 Experts available now in Live!

    Get 1:1 Help Now