I want to run my program as if I was running it using a terminal. Because I want to do different things depending on what attributes the user of the program provides while running it. Is there any way to do that in netbeans?
See this tutorial which explains how to specify command line arguments for a C++ project in Netbeans 7.2.
It works very similarly to Java, in that you right-click the project, select Properties, then the Run page, then set the command line options you want to feed your application when running it in Netbeans.
Related
I am making a c++ program in vscode. And i want to compile the c++ program using a specific command (for example g++ file_name.cpp -o file_name.exe). But cant understand how to do it using tasks in vscode?All i want is to be able to run the above compilation command on the powershell in vscode. How can i do it??
I recently found out how to do it.
You can download the coderunner extension in vscode.
Then go to the settings of this extension.
Then go to the executor_map.json folder.
In this folder you will see json pairs like key value pairs.
The 'key' is the language name and 'value' is the string which is directly pasted in the powershell of vscode.
So now you can easily modify the string to build your projects the way you want.
For Example in the case of C++ , I can give a g++ command with a lot of different flags like -Wall -Wshadow etc.
Code runner also auto detects the language you are working in. All you need to do is just press run, and your project will be build using your custom command.
If there is some other easier way you can share that too.
Just click "Terminal" then "New Terminal" in the toolbar above, you'll get a powershell terminal by default.
might be a stupid question, but I've just started using Netbeans 10 for a C++ project.
When I run/debug the project, I'd need to first execute a bash script which sets up the environment, and then execute the binary (including an argument to be passed):
#!/bin/bash
source setup_script.sh
./bin/my_program -c some_argument
I've tried just pointing Project Properties -> Run -> Run Command to the .sh file containing this launch script, but that won't do it (the Run / Debug buttons are either greyed our, or it'll tell me it doesnt recognize the executable type).
Is there any way to setup Netbeans to launch my application via this script, or any other way to achieve the same - e.g. setting up some sort of pre-run command that'd execute setup_script.sh in the same session?
Thanks!
I am trying to run a simple "Hello, world" console application but I am experiencing some errors when compiling that I am not familiar with. I have done a bit of research into similar problems with Qt but I haven't been able to find a solution. The closest solution I have come across was to change my Patch Command setting under:
Preferences -> Environment -> System -> Patch Command
to
usr/bin/xterm -e
However, when I try to do this it goes red indicating that I do not have this file.
Environment Preferences Window
The following image is a screenshot of what is displayed in the terminal window when attempting to compile my project.
Console Application Output
Any help on this problem would be much apprectiated! It is very frustrating having something like this hold me back!
Don't run your project in a terminal unless you actually select a working terminal, and that's all. The patch command is irrelevant in this anyway - it's not the terminal, but the patch command -- used to patch source code. You don't need it unless you explicitly use code patching. Go to Projects (Ctrl-5), click on the active Run configuration for your project, uncheck "Run in terminal", done.
Sorry if the documentation is clear on this, but I'm having a hard time running C++ files in OpenBR. I've tried running them through the terminal via g++ and via the QT interface to no avail.
Ultimately I don't see any way to create (nuanced) custom OpenBR scripts than by using the C++ API, but I can't even run the provided demos (age_estimation.cpp, face_recognition.cpp etc.).
I'm running this on Ubuntu for reference.
To run the example files you first have to download the dataset. The scripts/downloadDatasets.sh is in the openbr directory.
In the qt interface after opening the upmost CMakeList and building openbr you can select what to run on the bottom of the left toolbar, and then click the "play" arrow below to run the executable.
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.