繁体   English   中英

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

[英](C++/Visual Studio) cannot find or open pdb file & no printing to console

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

这是我的调试输出:

'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并尝试关闭屏蔽,如本帖所述: 我的程序被avast防病毒软件阻止,我还将整个文件夹'E:\\ Programming \\ *'添加到排除项中。

但是命令提示符仍然只弹出一秒钟,然后关闭,直到我看到任何东西为止。 据我所知,Avast并未通知它也在阻止任何内容。

控制台打开,然后关闭,因为程序已结束! 它并非旨在无限期地保持打开状态。

有些人在main的末尾写一些类似system("cls")类的hack来产生“请按任意键继续”提示,但这确实不合适,因为阻止输入不是程序语义的一部分。

如上一个“常见问题解答”所述,最好将IDE配置为在程序完成后保持控制台窗口打开。

在main返回0之前,您必须先给出程序说明以等待用户使用,因为现在,您的程序正按照您告诉它的操作:显示hello world并返回0并结束程序。 对于Windows,您只需使用system(“ pause”); 或者在这种情况下,您也可以使用getchar();。

另外,看起来您已经创建了Win32 Windows应用程序。 选择一个空的控制台应用程序可能会更好。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM