2016-07-07: 重新编译时vc90.pdb不是创建此预编译头时使用的pdb文件

使用VS2008在一个解决方案中包含多个项目时,当设置多个项目的中间目录为同一个目录时,在增量编译时出现“重新编译时vc90.pdb不是创建此预编译头时使用的pdb文件,请重新创建预编译头问题”,从而导致整个解决方案每次都必须重新全部生成。

在msdn上获得如下信息:

You may receive a "PRJ0008" or "C2471" or "C1083" or "D8022" or "LNK1103" or similar error message when you try to build a solution in Visual C++

Symptoms:

  • D8022 : Cannot open 'RSP00000215921192.rsp'
  • PRJ0008 : Could not delete file 'vc90.idb'.
  • C1083 : Cannot open program database file 'vc90.pdb'
  • C2471 : Cannot update program database 'vc90.pdb'
  • LNK1103 : debugging information corrupt.

Cause:

This problem occurs when all of the following conditions are true:

  1. You have a solution with more than one project in it.
  2. Two or more of the projects are not dependent on each other.
  3. You have parallel builds enabled. (Tools -> Options: Projects and Solutions, Build and Run: "maximum number of parallel project builds" is set to a value greater than 1)
  4. You are building on a system with multiple CPUs (cores).
  5. Two or more of the non-dependent projects are configured to use the same Intermediate and/or Output directory.
  6. A specific race condition in mspdbsrv.exe remains uncorrected.

Resolution:

To resolve the problem do one or more of the following:

  • Reconfigure the non-dependent projects to specify an Intermediate and Output directory that is different from one another, e.g. Output Directory = "$(SolutionDir)$(ProjectName)\$(ConfigurationName)", Intermediate Directory = "$(OutDir)".
  • Adjust your solution's project dependencies (Project -> Project Dependencies...) so that each is dependent on another.
  • Disable parallel builds.
  • Add the "/onecpu" boot option to your boot.ini file.
  • Change you BIOS settings to enable/use only one CPU.
  • File a problem report with Microsoft Technical Support and keep bugging the ____ out of them until they eventually fix mspdbsrv.

Status:

The problem is a combination of both a user project configuration error as well as a race condition in Microsoft's "mspdbsrv.exe" utility that does not properly handle more than one thread calling it at the same time for the same file resulting in the file's HANDLE being left open.

Additionally Visual Studio itself and/or its build system (VCBUILD and/or MSBUILD) (or all three!) should be made smart enough to detect and alert the user of such user errors so that corrective action can be taken.

This problem has been around for a LOOOOOONG time.

Applies to:

  • Microsoft Visual C++ 2005
  • Microsoft Visual C++ 2008
  • Others?

Respectfully submitted:

   "Fish" (David B. Trout)
fish@infidels.org

p.s:

   You're welcome. :)

Fish (David B. Trout)

最后,通过重新配置项目的中间输出目录成功解决上述问题。

遗留问题:在每个项目生成时,在对应的中间目录下都会生成vc90.pdb以及vc90.idb文件,如果全部项目的中间目录配置成相同目录,在项目依次生成过程中,后面生成的pdb文件会覆盖前面生成的pdb文件,从而导致修改部分源代码时,pdb文件可能不再是其对应项目生成的文件,因此需要重新生成整个解决方案。纯属猜测,后续可以使用逐步生成项目的方式验证结论。

 

https://social.msdn.microsoft.com/Forums/vstudio/en-US/25731965-bf98-4bb7-97b7-6d1a0b21b733/cant-open-vc90pdb-in-visual-c-2008-rebuild?forum=vcgeneral

posted on 2016-07-07 17:01  octocat 阅读( ...) 评论( ...) 编辑 收藏

转载于:https://www.cnblogs.com/zhouLee/p/5650781.html

预编译头文件今天在改一个很大的程序,慢慢看,慢慢改。突然发现一个.c文件,里面什么也没有,就几个头文件,我一看,我靠,这不是把简单的问题搞复杂了吗,随手删掉那个c文件。结果不能编译了,我靠:fatal error C1083: Cannot open precompiled header file: \'Debug/v13_3.pch\':No such file or directory怎么rebuild all都不行。上网查了一下,才搞懂了:----------------总结------如果工程很大,头文件很多,而有几个头文件又是经常要用的,那么1。把这些头文件全部写到一个头文件里面去,比如写到preh.h2。写一个preh.c,里面只一句话:#include "preh.h"3。对于preh.c,在project setting里面设置creat precompiled headers,对于其他.c文件,设置use precompiled header file//哈哈我试了一下,效果很明显,不用precompiled header,编译一次我可以去上个厕所,用precompiled header,编译的候,我可以站起来伸个懒腰,活动活动就差不多啦---------转载的文章----------预编译头的概念:所谓的预编译头就是把一个工程中的那一部分代码,预先编译好放在一个文件里(通常是以.pch为扩展名的),这个文件就称为预编译头文件这些预先编译好的代码可以是任何的C/C++代码--------甚至是inline的函数,但是必须是稳定的,在工程开发的过程中不会被经常改变。如果这些代码被修改,则需要重新编译生成预编译头文件。注意生成预编译头文件是很耗间的。同你得注意预编译头文件通常很大,通常有6-7M大。注意及清理那些没有用的预编译头文件。也许你会问:现在的编译器都有Time stamp的功能,编译器在编译整个工程的候,它只会编译那些经过修改的文件,而不会去编译那些从上次编译过,到现在没有被修改过的文件。那么为什么还要预编译头文件呢?答案在这里,我们知道编译器是以文件为单位编译的,一个文件经过修改后,会重新编译整个文件,当然在这个文件里包含的所有头文件中的东西(.eg Macro, Preprocesser )都要重新处理一遍。VC预编译头文件保存的正是这部分信息。以避免每次都要重新处理这些头文件预编译头的作用:根据上文介绍,预编译头文件的作用当然就是提高便宜速度了,有了它你没有必要每次都编译那些不需要经常改变的代码。编译性能当然就提高了。预编译头使用:要使用预编译头,我们必须指定一个头文件,这个头文件包含我们不会经常改变的代码和其他的头文件,然后我们用这个头文件来生成一个预编译头文件.pch文件)想必大家都知道 StdAfx.h这个文件。很多人都认为这是VC提供的一个“系统级别”的,编译器带的一个头文件。其实不是的,这个文件可以是任何名字的。我们来考察一个典型的由AppWizard生成的MFC Dialog Based 程序的预编译头文件。(因为AppWizard会为我们指定好如何使用预编译头文件,默认的是StdAfx.h,这是VC起的名字)。我们会发现这个头文件里包含了以下的头文件:#include // MFC core and standard components#include // MFC extensions#include // MFC Automation classes#include // MFC support for Internet Explorer 4Common Controls#include 这些正是使用MFC的必须包含的头文件,当然我们不太可能在我们的工程中修改这些头文件的,所以说他们是稳定的。那么我们如何指定它来生成预编译头文件。我们知道一个头文件是不能编译的。所以我们还需要一个cpp文件来生成.pch 文件。这个文件默认的就是StdAfx.cpp。在这个文件里只有一句代码就是:#include “Stdafx.h”。原因是理所当然的,我们仅仅是要它能够编译而已?D?D?D也就是说,要的只是它的.cpp的扩展名。我们可以用/Yc编译开关来指定StdAfx.cpp来生成一个.pch文件,通过/Fp编译开关来指定生成的pch文件的名字。打开project ->Setting->C/C++ 对话框。把Category指向Precompiled Header。在左边的树形视图里选择整个工程 Project Options(右下角的那个白的地方)可以看到 /Fp “debug/PCH.pch”,这就是指定生成的.pch文件的名字,默认的通常是 .pch(我的示例工程名就是PCH)。然后,在左边的树形视图里选择StdAfx.cpp.//这只能选一个cpp文件!这原来的Project Option变成了 Source File Option(原来是工程,现在是一个文件,当然变了)。在这里我们可以看到 /Yc开关,/Yc的作用就是指定这个文件创建一个Pch文件。/Yc后面的文件名是那个包含了稳定代码的头文件,一个工程里只能有一个文件的可以有YC开关。VC就根据这个选项把 StdAfx.cpp编译成一个Obj文件和一个PCH文件。然后我们再选择一个其它的文件来看看,//其他cpp文件在这里,Precomplier 选择了 Use ???一项,头文件是我们指定创建PCH 文件的stdafx.h文件。事实上,这里是使用工程里的设置,(如图1)/Yu”stdafx.h”。这样,我们就设置好了预编译头文件。也就是说,我们可以使用预编译头功能了。以下是注意事项:1):如果使用了/Yu,就是说使用了预编译,我们在每个.cpp文件的最开头,我强调一遍是最开头,包含 你指定产生pch文件.h文件(默认是stdafx.h)不然就会有问题。如果你没有包含这个文件,就告诉你Unexpected file end. 如果你不是在最开头包含的,你自己试以下就知道了,绝对有很惊人的效果?..fatal error C1010: unexpected end of file while looking for precompiledheader directiveGenerating Code...2)如果你把pch文件不小心丢了,编译的候就会产生很多的不正常的行为。根据以上的分析,你只要让编译器生成一个pch文件。也就是说把 stdafx.cpp(即指定/Yc的那个cpp文件)从新编译一遍。当然你可以傻傻的 Rebuild All。简单一点就是选择那个cpp文件,按一下Ctrl + F7就可以了。不然可是很浪费间的哦。//呵呵,如果你居然耐着性子看到了这里,那么再回到帖子最开始看看我的总结吧!
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值