简体   繁体   中英

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

This is my first time using C++ and Visual Studio Community (I've only taken classes in Java and used Eclipse), and just want to try printing to the console using Visual Studio Community, and am having trouble.

This is my output from the debug:

'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).

And this is my actual code:

// 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;
}

I've checked other people's questions who had the same PDB file problem, and the consensus seems to be just "don't worry about it, it's for debugging." Which is fine, but I still don't know why I don't see "Hello world." printed anywhere. I've also tried running Visual Studio as administrator, if that means anything.

I use Avast and tried turning off the shields like this post said: My programs are blocked by avast anti-virus I also added the whole folder 'E:\\Programming\\*' to the exclusions.

But the command prompt still only pops up for a second, and closes before I can see anything. As far as I can tell, Avast is not notifying of that it's blocking anything as well.

The console opens and then closes because the program ended! It is not designed to stay open indefinitely.

Some people write hacks like system("cls") at the end of main to produce a "Please press any key to continue" prompt, but really this is not appropriate as blocking on input is not part of the semantics of your program.

You would be better off configuring your IDE to keep the console window open after the program has finished, as described in this previous Q&A .

before main returns 0 you have to give the program instructions to wait for the user because right now, your program is doing exactly what you've told it to: display hello world and return 0 and end the program. for windows you can simply use system("pause"); or in this case you could also use getchar();.

also, looks like you've created a win32 windows application. you would probably be better off choosing an empty console application.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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