从C++休息了很长时间之后,我试图在VS2010中编译一个非常简单的C++项目。我创建了一个Win32 C++控制台空项目,选择了“没有预编译的头文件”和“没有其他MS库”。我添加了以下main.cpp文件:

#include <iostream>
#include <string>

using namespace std;

class A
{
public:
  string name;
};

int main(int argc, char** argv)
{
  return 0;
}

当我编译时,我得到了臭名昭著的错误:
1>------ Build started: Project: TestGetline, Configuration: Debug Win32 ------
1>  main.cpp
1>main.cpp : fatal error C1033: cannot open program database ''
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

以下是一些事实:
  • 我将Windows 7 64位作为具有Desktop Parallels的VM运行:版本6.1.7601 Service Pack 1 Build7601。VM已选中“共享配置文件”,这意味着文档,下载等文件夹在OSX和Windows 7之间共享。
  • VS 2010版本:Microsoft Visual Studio 2010版本10.0.40219.1 SP1Rel,Microsoft .NET Framework版本4.0.30319 SP1Rel
  • 我用于启动VS 2010的链接已选中“以兼容模式运行此程序以用于Windows XP(Service Pack 3)”。未选中以管理员身份运行此程序。
  • 我尝试了其他帖子中建议的一些方法,但均无效果。例如,我尝试杀死mspdbsrv.exe(已关闭VS 2010),手动删除调试目录,然后重新编译项目。我试图将调试信息格式更改为与C7兼容,但是随后出现另一个错误(main.cpp:致命错误C1074:“IDB”是PDB文件的非法扩展名:)。我试图以管理员身份运行VS 2010,但该错误却像 bug 一样顽固。是的,尝试所有这些程序时都在运行防病毒软件。

  • 还有其他想法吗?一个人不禁要问,是否有任何人在VS 2010中进行C++开发。目前无法升级到VS 2012或2013。

    谢谢

    只是更新,这是在编译日志文件中失败的构建任务的输出:
     1>Target "ClCompile" in file "C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\Platforms\Win32\Microsoft.Cpp.Win32.Targets" from project "C:\projects\cpp\TestGetLine\TestGetline\TestGetline.vcxproj" (target "_ClCompile" depends on it):
       Using "Delete" task from assembly "Microsoft.Build.Tasks.v4.0, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a".
       Task "Delete"
       Done executing task "Delete".
       Task "CL" skipped, due to false condition; ('%(ClCompile.PrecompiledHeader)' == 'Create' and '%(ClCompile.ExcludedFromBuild)'!='true') was evaluated as ('' == 'Create' and ''!='true').
       Using "CL" task from assembly "Microsoft.Build.CppTasks.Win32, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a".
       Task "CL"
         Forcing recompile of all source files due to missing PDB "Debug\vc100.pdb".
         Environment Variables passed to tool:
           VS_UNICODE_OUTPUT=1328
         c:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\bin\CL.exe /c /Zi /nologo /W3 /WX- /Od /Oy- /D WIN32 /D _DEBUG /D _CONSOLE /D _UNICODE /D UNICODE /Gm /EHsc /RTC1 /MDd /GS /fp:precise /Zc:wchar_t /Zc:forScope /Fo"Debug\\" /Fd"Debug\vc100.pdb" /Gd /TP /analyze- /errorReport:prompt main.cpp
         Tracking command:
         C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\bin\NETFX 4.0 Tools\Tracker.exe /d C:\Windows\Microsoft.NET\Framework\v4.0.30319\FileTracker.dll /i C:\projects\cpp\TestGetLine\TestGetline\Debug /r C:\PROJECTS\CPP\TESTGETLINE\TESTGETLINE\MAIN.CPP /b MSBuildConsole_CancelEvent7f4b09d9e64d472facf5c417755b2cdd  /c "c:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\bin\CL.exe"  /c /Zi /nologo /W3 /WX- /Od /Oy- /D WIN32 /D _DEBUG /D _CONSOLE /D _UNICODE /D UNICODE /Gm /EHsc /RTC1 /MDd /GS /fp:precise /Zc:wchar_t /Zc:forScope /Fo"Debug\\" /Fd"Debug\vc100.pdb" /Gd /TP /analyze- /errorReport:prompt main.cpp
         main.cpp
     1>main.cpp : fatal error C1033: cannot open program database ''
         The command exited with code 2.
       Done executing task "CL" -- FAILED.
     1>Done building target "ClCompile" in project "TestGetline.vcxproj" -- FAILED.
     1>Done Building Project "C:\projects\cpp\TestGetLine\TestGetline\TestGetline.vcxproj" (build target(s)) -- FAILED.
    

    最佳答案

    为了解决此问题,我删除了pdb文件(在备份之后),然后构建了它。

    09-26 23:08
    查看更多