在调试模式下尝试在 VS2010 (VC100) 中使用预编译头时,如何消除错误 C2859?
我正在尝试升级旧的解决方案以使用 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
感谢一位同事,我得到了答案。
问题在于 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.
当编译一个项目时,我在 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 defaultvc80.pdb
)在 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.
也许您的发布版本配置为写入文件 [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.
以下是我在 Visual Studio 2008 上修复此错误的方法:
背景:
错误原因:
修复:
Here's how I just fixed this error on Visual Studio 2008:
Background:
Cause of error:
The fix: