11

I am trying to upgrade an old solution to use VS2010 (VC100).

I have it setup so that stdafx.cpp will create a precompiled header stdafx.pch from stdafx.h. Then all the other .cpp files that include stdafx.h are instructed to use the precompiled header.

These posts helped me get this far:

Now all is fine when I build in release mode. However when I try and build in debug mode I get a whole heap of errors saying:

Error 1 error C2859: [removed]\debug\vc100.idb is not the idb file that was used when this precompiled header was created, recreate the precompiled header.

I believe that this .idb file is an intermediate debug file created by Visual Studio.

Why am I getting this error? In other words why did it not use this .idb file when it created the precompiled header?

I'm not sure what further information you need to be able to give me answer so just ask if there is more information that I need to provide.

Community
  • 1
  • 1
steinybot
  • 5,491
  • 6
  • 37
  • 55

5 Answers5

5

Thanks to a colleague I got the answer.

The problem was that stdafx.cpp had Debug Information Format set to Program Database (/Zi) where as all the other files had it set to Program Database for Edit and Continue (/ZI).

Changing them all to Program Database for Edit and Continue (/ZI) and doing a full rebuild solved the problem.

I guess the upgrade screwed it up somehow.

steinybot
  • 5,491
  • 6
  • 37
  • 55
5

I've hit this error with VS2005 when compiling a project where the $(ProjectName) is different from the actual output file of the project (i.e. Linker > Output File isn't set to the default of $(OutDir)\$(ProjectName).exe but to something else, e.g. $(OutDir)\$(ProjectName)-custom_postfix.exe)

In this case, and apparently only when doing a Rebuild-Project-Only, the vc80.pdb seems to be looked up wrongly.

What helped me was to additionally set C/C++ > Output Files > Progam Database File Name to $(IntDir)\$(TargetName).pdb. (Instead of the default vc80.pdb)

Martin Ba
  • 37,187
  • 33
  • 183
  • 337
  • I had a similar situation (using custom name, was working fine, then suddenly encountered this error) but the solution was as simple as manually deleting the output files and rebuilding. – jacobq Nov 01 '16 at 12:16
  • @iX3: Deleting .pdb file helps only until you try to rebuild solution. Then it will fail with the same error again. The initial answer by Martin Ba fixed the issue for me. – c00000fd Oct 24 '17 at 00:03
1

select Disable for the Debug Information Format in the Properties page for stdafx.cpp, then go back and select Inherit from parent worked for me.

Joe
  • 91
  • 2
  • 2
0

Maybe your release build is configured to write file [removed]\debug\vc100.idb instead of [removed]\release\vc100.idb? Check the project settings for your release build and make sure there are no hardcoded path components like that.

Windows programmer
  • 7,871
  • 1
  • 22
  • 23
  • A release build does not generate an idb file since it is only for debugging. Hence why the release build works and the debug doesn't. – steinybot Jul 01 '10 at 22:11
  • A release build by default does not generate an idb file but you can configure (most likely by accident) for it to do so. – Windows programmer Jul 02 '10 at 00:02
  • Thanks I figured that out the hard way lol. It was all to do with the Debug Information Format setting. – steinybot Jul 04 '10 at 21:55
0

Here's how I just fixed this error on Visual Studio 2008:

Background:

  • I have a solution that contains two sub-projects.
  • One project compiles the .dll;
  • One project compiles the .exe that used this .dll;
  • The .exe project is dependent on the .dll project;
  • Problem: I had both of the projects dumping their output into the same directory, i.e. both "OutPutDirectory" and "IntermediateDirectory" set to write to a common directory in the root, "../$(ConfigurationName)".

Cause of error:

  • The cause of this error was that when the .dll project was compiled, it created the precompiled header (*.pch) in the same directory as the .exe directory, and when the .exe project was compiled, it promptly overwrote the precompiled header (*.pch) from the .dll project.

The fix:

  • To fix this, I changed the "IntermediateDirectory" for both sub-projects to "temp", so that the temporary files (including the precompiled header files) were written to different directories.
Contango
  • 76,540
  • 58
  • 260
  • 305