(C ++ / Visual Studio)无法找到或打开pdb文件而无法打印到控制台

问题描述 投票:0回答:2

这是我第一次使用C ++和Visual Studio社区(我只使用Java编写类并使用Eclipse),并且只想尝试使用Visual Studio社区打印到控制台,并且遇到了麻烦。

这是我的调试输出:

'HelloWorld.exe' (Win32): Loaded 'E:\Programming\C++Projects\HelloWorld\Debug\HelloWorld.exe'. Symbols loaded.
'HelloWorld.exe' (Win32): Loaded 'C:\Windows\SysWOW64\ntdll.dll'. Cannot find or open the PDB file.
'HelloWorld.exe' (Win32): Loaded 'C:\Windows\SysWOW64\kernel32.dll'. Cannot find or open the PDB file.
'HelloWorld.exe' (Win32): Loaded 'C:\Windows\SysWOW64\KernelBase.dll'. Cannot find or open the PDB file.
'HelloWorld.exe' (Win32): Loaded 'C:\Windows\SysWOW64\apphelp.dll'. Cannot find or open the PDB file.
'HelloWorld.exe' (Win32): Loaded 'C:\Windows\SysWOW64\vcruntime140d.dll'. Cannot find or open the PDB file.
'HelloWorld.exe' (Win32): Loaded 'C:\Windows\SysWOW64\ucrtbased.dll'. Cannot find or open the PDB file.
'HelloWorld.exe' (Win32): Loaded 'C:\Windows\SysWOW64\msvcp140d.dll'. Cannot find or open the PDB file.
'HelloWorld.exe' (Win32): Loaded 'C:\Windows\SysWOW64\advapi32.dll'. Cannot find or open the PDB file.
'HelloWorld.exe' (Win32): Loaded 'C:\Windows\SysWOW64\msvcrt.dll'. Cannot find or open the PDB file.
'HelloWorld.exe' (Win32): Loaded 'C:\Windows\SysWOW64\sechost.dll'. Cannot find or open the PDB file.
'HelloWorld.exe' (Win32): Loaded 'C:\Windows\SysWOW64\rpcrt4.dll'. Cannot find or open the PDB file.
'HelloWorld.exe' (Win32): Loaded 'C:\Windows\SysWOW64\sspicli.dll'. Cannot find or open the PDB file.
'HelloWorld.exe' (Win32): Loaded 'C:\Windows\SysWOW64\cryptbase.dll'. Cannot find or open the PDB file.
'HelloWorld.exe' (Win32): Loaded 'C:\Windows\SysWOW64\bcryptprimitives.dll'. Cannot find or open the PDB file.
'HelloWorld.exe' (Win32): Loaded 'C:\Windows\SysWOW64\kernel.appcore.dll'. Cannot find or open the PDB file.
The thread 0x10c8 has exited with code 0 (0x0).
The thread 0x1a98 has exited with code 0 (0x0).
The thread 0x1380 has exited with code 0 (0x0).
The program '[1592] HelloWorld.exe' has exited with code 0 (0x0).

这是我的实际代码:

// HelloWorld.cpp : Defines the entry point for the console application.
//

#include "stdafx.h"
#include "iostream"
#include "sstream"
using namespace std;

int main()
{
    cout << "Hello world.";
    return 0;
}

我已经检查了其他人的问题,他们有相同的PDB文件问题,而且共识似乎只是“不用担心它,而是用于调试”。这很好,但我仍然不知道为什么我看不到“Hello world”。随处印刷。我也尝试以管理员身份运行Visual Studio,如果这意味着什么的话。

我使用Avast并尝试关闭盾牌,就像这篇文章所说:My programs are blocked by avast anti-virus我还将整个文件夹'E:\ Programming \ *'添加到排除项中。

但是命令提示符仍然只会弹出一秒钟,然后在我看到任何内容之前关闭。据我所知,Avast没有通知它也阻止任何事情。

c++ visual-studio
2个回答
0
投票

控制台打开然后关闭,因为程序结束了!它不是为了无限期保持开放而设计的。

有些人在system("cls")结尾处编写像main这样的hack来生成“请按任意键以继续”提示,但实际上这不合适,因为输入上的阻塞不是程序语义的一部分。

最好配置IDE以在程序完成后保持控制台窗口打开,如this previous Q&A中所述。


0
投票

在main返回0之前,你必须给程序指令等待用户,因为现在,你的程序完全按照你告诉它的方式执行:显示hello world并返回0并结束程序。对于Windows,你可以简单地使用系统(“暂停”);或者在这种情况下,您也可以使用getchar();.

另外,看起来你已经创建了一个win32 windows应用程序。你最好选择一个空的控制台应用程序。

© www.soinside.com 2019 - 2024. All rights reserved.