VC++ 2013 Debugger Freezes [duplicate] - c++

This question already has an answer here:
Running my C++ code gives me a blank console
(1 answer)
Closed 7 years ago.
Whenever I press F5 to compile and run a C++ program in Visual Studio 2013, the program stops responding without outputting any error. The cursor becomes busy and the application just hangs.
Here are the steps:
Create a new Visual C++ console project
Unselect everything to make it an empty project.
Add the following code to a main.cpp:
#include <iostream>
int main() {
std::cout << "Hello World!" << std::endl;
std::cin.get();
return 0;
}
Compile: works fine
Run with debugger: Mouse turns busy and app becomes unresponsive.
It seems to work when I run without debugging, but there are no console outputs to check. Updated to latest VS2013 release and rebooted the computer just in case there's an error. Running in Windows 10.

There were at least two times here at Stack Overflow where others had something similar happen, and it was due to Avast anti-virus software. If you're using Avast, you might want to see if there's a workaround.

Related

Necessary extensions for VS code with Windows OS

I am a first time C++ user, and I have been working for 8 hours trying to build and compile the simple "Hello World" program with C++ in Visual Studio Code. I have CygWin64, but I'm not sure if it's connected to my VSCode. I have installed the extensions C/C++, C/C++ Compile Run, C++ Intellisense, Clang-Format, and Easy C++ projects.
So far I have tried
#include <iostream.h>
main()
{
cout<< "Hi there";
return 0;
}
and
#include <iostream.h>
int main() {
std::cout << "Hello Easy C++ project!" << std::endl;
}
Using iostream.h helped me to get to work (it wouldn't at first), but I'm not sure if that is helpful, since other posts say that .h is very archaic. I have also tried editing my c_cpp_properties.json file. Sadly, I still get the message:
"> Executing task: bash -c "make run" <
'bash' is not recognized as an internal or external command,
operable program or batch file.
The terminal process terminated with exit code: 1
Terminal will be reused by tasks, press any key to close it."
I am not sure if I need to install an alternative to Clang (I haven't found one), or run something initially on Cygwin64.
I have been looking online for suggestions and following pages such as https://dev.to/acharluk/developing-c-with-visual-studio-code-4pb9 and https://github.com/Microsoft/WSL/issues/1598, but I still can't seem to get around this problem.
Any help would be very appreciated.
Thanks,
Anne

IDE showing blank console

It's been days since I try to make my IDE (Code::Blocks version 13.12, I tried on 10.05 too) work. Any program (including a simple Hello World! program) I would make would show a black console showing nothing but an " _ ". I have made an exception in my antivirus (Avast!) for the file containing the IDE) but the same thing happens . I have tried re-installing twice, i have tried resetting the compiler and debugger's settings to default, auto-detecting toolchain executables ,but the same thing happens.
I have tried rebooting my computer several times, same thing happens.
I would like to know what I can do to solve this problem , because I don't want to get another complicated compiler (I am a beginner,) , as Code::Blocks fits my needs perfectly.
The following codes produces a blank console:
#include <iostream>
int main()
{
std::cout << "Hello world!\n";
return 0;
}
I had the same exact problem, with Eclipse, Visual Studio and then with Code::Blocks (I tested them all). I suggest you follow this video tutorial after you confirm the problem persists with a second IDE : https://www.youtube.com/watch?v=zOGU8fC3bvU&index=6&list=LLHcXdIeBMN4XYRZAk4IeXmg&spfreload=10 . It will take you step by step on how to install a given compiler.

"Hello world!" freeze in c++

I tried to compile a simple Hello World in C++ to test that my Visual Studio 2013 on my Windows 10 works well but I've a problem. My program compile but when I run, it freeze. It's an empty Win32 Console Application with a "main.cpp" :
#include <iostream>
using namespace std;
int main()
{
cout << "Hello world!";
return 0;
}
If I launch it from Visual Studio in debug (with "Run"), Visual Studio freeze and I need to kill its task.
If I launch it with the executable or with "Run without Debugging", nothing appear, "System" process doesn't want to free the execution and I can't recompile without restart the computer because of that.
I am confused. If somebody have an idea of what's happening, please help me.
Update 1 : I repair my installation. Same problem. Breakpoint doesn't help. It seems to freeze before. And also no trace of a task in the task manager when launched without debugging.
It was my antivirus' fault (in my case, Avast). I made it ignore my Visual Studio projects and it works. Solved by #Blastfurnace.

Debugging C++ in Netbeans

I am very new to work c++ Programs with Netbeans IDE in Ubuntu. I wrote a simple Hello World Program and tried to debug it using step Into. When I Click Step Into Option From Debug Menu I got new window opened in the name of " Diassembly(main) " . The Debug process didn't reach my source code line at any way. I repeatedly click Step Into Function At last the process got end Without Tracing my source code line. But In the Debug output window I got the Correct Result.
#include <iostream>
using namespace std;
int main()
{
cout<<"Hello";
cout<<"World";
}
Why This process Control goes to the Diassembly (main) window ? How to rectify this problem ?
You must compile with -g option, otherwise the debugger won't be able to stop on a breakpoint. As for disassembling window - I can't reproduce that (I'm on Netbeans 7.4 in Ubuntu 13). You should just close the window if you don't need it.
First, you have to toggle a break point in your code by clicking on the line number of the line you want to stop in source window, if you did not. Then hit Debug.
Don't step into function that you not build from source, just step over it.
Pehaps that there is an answer here (i can't comment sorry)
"No source available for main()" error when debugging simple C++ in Eclipse with gdb

C++ on windows closes a program immediately after launching

I installed minGW and the eclipse CDT, and the console keeps doing something weird. The code of the program is
using namespace std;
#include <iostream>
int main() {
cout << "Hello, windows (8, c++)" << endl;
//system("PAUSE");
return 0;
}
You all know it, its the Hello World program. Now when I run this the Eclipse console displays some stuff about building, and then goes blank. And when I navigate to the HelloWorldProgram.exe in the explorer and run it, a windows flashes up and displays "hello world", but then immediately closes. When I do this on Mac OSX there's no problem, and the windows stays up until I decide to close it. Now I know there's a command
system("PAUSE") //I dont know what I need to import to use this. Could you tell me that too?
Which will give me more or less the same effect, but I'd like to know why Windows does it differently from OSX, and what I can do to fix it (bc this annoys the crap out of me).
Looking forward to your replies!
This happens on Windows because this is just the behavior of the Windows console. You'll have to open up the console manually and then running your program through the console you've opened if you don't want the window to close automatically once the program has executed.
You may want to take a look at these:
What is the Best Practice for Combating the Console Closing Issue?
https://superuser.com/questions/186562/how-can-i-keep-the-terminal-open
Don't use system("pause"), it's wrong for a multitude of reasons (read more about it here).
Put cin.get() before return and the window will stay open until you press enter.
If you want to just run your console program, you should open a console, and run it.
Apparently, the OSX version of Eclipse is configured to open a console, and run the program, and not close it. Maybe you can configure the Win version so, too.
You shouldn't meddle with your program to behave differently on another platform, instead wrap it into something that 'adapts' the behaviour.
Probably, you can tell eclipse to use "cmd /c 'yourprogram.exe && pause'", to open a command window and have it execute your program and then pause.
Just add getch(); before return, and add #include <conio.h>.