Running CLion on the System console (like Visual Studio) - c++

I am trying to run a simple C++ program on CLion. The problem is that when I try to compile and run it, it shows the result in the application console. I want to run on the System console like the Visual Studio runs the output of the console apps. Is there a way of doing this. I use MINGW compiler.

You can use an external terminal, do these steps.
(top menu) run\ edit Configurations
tick 'run in external console'

Well, if anyone is still around wanting to open an external cmd window on run, there is a way to do it on Windows as well:
Go to Run > Edit Configurations
For the executable select C:\Windows\System32\cmd.exe
For program arguments use: /c "start cmd.exe #cmd /k "ProjectName.exe""
For working directory set the cmake debug (or release) folder
Save and select the profile from the dropdown right next to the run button
Note: In the third step /k can be replaced with /c to make the window close after the program is run (with /c its more like visual studio and with /k its more like code blocks)

I am not sure about Windows but in linux you can do it using this answer.
You might be able to change the gnome-terminal to cmd if you are using windows but you will probably need to change the "Program Arguments" too.

the above answer works fine in windows also. In working directory you can set this $CMakeCurrentBuildDir$
enter image description here

Related

How can I change the default behaviour of "Terminal: Explorer Kind" in VS Code Settings? [duplicate]

I have a Console application open in VS Code. When I press Ctrl-F5, the output of my program is displayed in a DEBUG CONSOLE window, along with other text.
How do I get Visual Studio code to launch my program in a new console window?
As documented here this can be achieved using this setting:
"console": "externalTerminal"
The settings file is in the solution directory: .vscode/launch.json .
When you're just using Tasks and not Launchers, you can follow the advice here.
For me on Linux, I changed my shell command in VSCode from command to gnome-terminal -e command. That did the trick; that's all I had to do.
Note that if you do this you can get rid of the presentation option set from your task.

Eclipse CDT - how to run compiled .exe in external console (cmd.exe)

Is there a way to run compiled CDT program inside Eclipse IDE, but not in Eclipse terminal, but rather in new cmd.exe window? Some Run configuration or External Tools configuration?
Just like in QT, when you run compiled console application.
I googled this, on my mind, simple question, but (what is strange for me) I didn't find the answer.
From Eclipse CDT forum, from Mr Klaus:
Edit the Run Configuration:
On the Main page set C/C++ Application to:
${system_path:cmd.exe}
On the Arguments page add (adjust path and program name):
/C "start .\Debug\hello.exe"
On the Common page untick "Allocate console".
In the example above the console windows will close immediately if hello.exe ends. If you don't want that, use this version on the Arguments page:
/C "start ${system_path:cmd.exe} /K .\Debug\hello.exe"
Btw, you could use the same concept for External Tools configuration also!
In my case i was need to change arguments:
/C "start /WAIT .\Debug\hello.exe"

Stop command prompt from opening when running compiled .exe

When I build, compile and run my Visual Studio project, a command prompt also opens with the window. It does this with the compiled .exes as well as in the dev environment. Is there a way to stop the command prompt from opening for the compiled .exes?
You can switch the subsystem in the linker settings from "CONSOLE" to "WINDOWS", which will stop the OS from creating an initial console window for the process. It can still create one afterwards though, in which case you'd have to modify the code.
Try switching compilation mode to 'Release'. Change build target to another than console (depends on your current project, for example Win32 Application).

Qt - Qt Command Prompt

So I found an excellent video where it teaches me about static compile. But in there it doesn't show where he got the "Qt Command Prompt" from. I searched alot but didn't find it in the directory. What do I do? Can anybody tell me where it's located? I even searched for it in Explorer but didn't find it.
Just add the following paths:
<qtdir>\mingw\bin;
<qtdir>\Desktop\Qt\<qtver>\mingw\bin;
<qtdir>Madde\bin\
to your %PATH% environment variable, and the default command prompt (cmd.exe) will become what you need. Don't forget to restart an already opened cmd.exe after editing %PATH%.
What OS do you use?
For exanple, here you can find how to edit %PATH% on win7.
The Qt command prompt is simply a normal cmd.exe session where the paths to the Qt libraries and binaries have been added to the environment.
It depends on how you installed Qt (using the SDK, build from source, etc.). If you used the SDK, a shortcut should have been installed in your Start menu. My Qt command prompt is at:
C:\Qt\4.8.2\bin\qtvars.bat vsvars
That being said, I rarely use the Qt command prompt. If you use the normal Visual Studio command prompt, then navigate to your Qt "bin" folder, you should be able to execute the command you need, like configure.
If you are using Windows 8, just type "Qt 5.4 for Desktop" after pressing the windows button.
Actually in windows 8 just typing "qt" in start menu, will give you the suggestion.

Easy way to run command line programs C++ - Windows 7

I am trying to find an easier way to test my command line application. It has arguments so I run it from a command prompt. My process is this:
Build
Go to the output
Open command prompt
Change directory
Run it
There has to be an easier way not only to debug but to open a command prompt in the current folder.
Thank you for your time.
If you go to the project properties, Debugging settings, you can set the working directory and parameters. If you use the same parameters all of the time, you can enter those in on that screen as well. Then just F5 or Ctrl+F5 to run.
Set a breakpoint at the end of the code to keep it from going away after it is done.
See Debugging with command-line parameters in Visual Studio
Alternatively, you should be able to use a shell script (or Python os.system()) to automate some of those steps.
To open a command prompt in the current directory using explorer, you can shift+right click->Open Command Window Here. That will save a little time.
If you're using Visual Studio, pressing F5 will run the code in the debugger, and Ctrl+F5 will run the code normally. Just remember to include a cin.get() statement at the end or the terminal window will close before you can read the output.
Other IDEs should have similar functions. Check in the Run or Debug menu.
EDIT: Sorry, didn't see that you're asking about running it with arguments. In VS, in Project Properties there are the Debugging settings. Within that, there is a field called Command Arguments. These will get passed to the application when you run it from within VS.
In project properties under debugging you can set the command line arguments (and environment variables) when debugging,
There is an extension called PowerCommands for Visual Studio 2010 that can be installed from Tools -> Extension Manager. It includes a Open Containing Folder and Open Command Prompt functionality that gets added to your right-click menu in the Solution Explorer.