在调试模式下尝试在 VS2010 (VC100) 中使用预编译头时,如何消除错误 C2859?

发布于 2024-09-07 09:34:17 字数 701 浏览 6 评论 0原文

我正在尝试升级旧的解决方案以使用 VS2010 (VC100)。

我进行了设置,以便 stdafx.cpp 将从 stdafx.h 创建预编译头 stdafx.pch 。然后,所有其他包含 stdafx.h 的 .cpp 文件都被指示使用预编译头。

这些帖子帮助我走到了这一步:

现在,当我在发布模式下构建时,一切都很好。然而,当我尝试在调试模式下构建时,我收到一大堆错误:

错误 1 ​​错误 C2859:[已删除]\debug\vc100.idb 不是创建此预编译头时使用的 idb 文件,请重新创建预编译头。

我相信这个 .idb 文件是 Visual Studio 创建的中间调试文件。

为什么我会收到此错误?换句话说,为什么它在创建预编译头时不使用这个 .idb 文件?

我不确定您需要什么进一步的信息才能给我答案,所以只需询问我是否需要提供更多信息。

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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(5

绅刃 2024-09-14 09:34:17

感谢一位同事,我得到了答案。

问题在于 stdafx.cpp 将调试信息格式设置为程序数据库 (/Zi),而所有其他文件都将其设置为用于编辑并继续的程序数据库 (/ZI)。

将它们全部更改为用于编辑并继续的程序数据库 (/ZI) 并进行完全重建解决了问题。

我猜升级不知何故把它搞砸了。

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.

谁的新欢旧爱 2024-09-14 09:34:17

当编译一个项目时,我在 VS2005 中遇到了这个错误,其中 $(ProjectName) 与项目的实际输出文件不同(即 Linker >输出文件未设置为默认值$(OutDir)\$(ProjectName).exe,而是设置为其他内容,例如$(OutDir)\$(ProjectName) -custom_postfix.exe

在这种情况下,显然在执行 Rebuild-Project-Only 时,vc80.pdb 似乎被错误地查找。

对我有帮助的是额外设置 C/C++ >输出文件>程序数据库文件名$(IntDir)\$(TargetName).pdb。 (而不是默认的 vc80.pdb

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)

韶华倾负 2024-09-14 09:34:17

在 stdafx.cpp 的“属性”页面中为“调试信息格式”选择“禁用”,然后返回并选择“从为我工作的父级继承”。

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.

我的奇迹 2024-09-14 09:34:17

也许您的发布版本配置为写入文件 [removed]\debug\vc100.idb 而不是 [removed]\release\vc100.idb?检查发布版本的项目设置,并确保不存在类似的硬编码路径组件。

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.

无语# 2024-09-14 09:34:17

以下是我在 Visual Studio 2008 上修复此错误的方法:

背景:

  • 我有一个包含两个子项目的解决方案。
  • 一个项目编译.dll;
  • 一个项目编译了使用这个.dll的.exe;
  • .exe项目依赖于.dll项目;
  • 问题:我让两个项目都将其输出转储到同一目录中,即“OutPutDirectory”和“IntermediateDirectory”都设置为写入根目录中的公共目录“../$(ConfigurationName)”。

错误原因:

  • 导致该错误的原因是.dll工程在编译时,在与.exe目录相同的目录下创建了预编译头(*.pch),而当.dll工程在.exe目录下时,就创建了预编译头(*.pch)。 exe 项目被编译后,它立即覆盖了 .dll 项目中的预编译头 (*.pch)。

修复:

  • 为了修复这个问题,我将两个子项目的“IntermediateDirectory”更改为“temp”,以便将临时文件(包括预编译头文件)写入不同的目录。

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.
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文