KDevelop5/Manual/Running programs: Difference between revisions

From KDE Wiki Sandbox
(Created page with "<languages /> <translate> == Running programs in KDevelop == <!--T:1--> <!--T:2--> Once you have built a program, you will want to run it. To do this, need to configure ''L...")
 
(Marked this version for translation)
 
(5 intermediate revisions by 3 users not shown)
Line 5: Line 5:


<!--T:2-->
<!--T:2-->
Once you have built a program, you will want to run it. To do this, need to configure ''Launches'' for your projects. A ''Launch'' consists of the name of an executable, a set of command line parameters, and an execution environment (such as "run this program in a shell", or "run this program in the debugger").
Once you have built a program, you will want to run it. To do this, need to configure ''Launches'' for your project. A ''Launch'' consists of the name of an executable, a set of command line parameters, and an execution environment (such as "run this program in an external terminal", or "run this program in the debugger").


</translate><span id="Setting up launches in KDevelop"></span><translate>
</translate><span id="Setting up launches in KDevelop"></span><translate>
Line 12: Line 12:


<!--T:4-->
<!--T:4-->
[[Image:kdevelop-2.png|thumb|400px|center]]
[[File:Kdevelop-nano-launch-config.png|500px|thumb|center]]


<!--T:5-->
<!--T:5-->
To set this up go to menu item <menuchoice>Run -> Configure launches</menuchoice>, highlight the project you want to add a launch for, and click on the {{Plus}} button. Then enter the name of the executable, and the path where you want to run the program. If running the executable depends on building the executable and/or other libraries first, then you may want to add them to the list at the bottom: select <menuchoice>Build</menuchoice> from the dropdown menu, then hit the {{Icon|folder}} symbol to the right of the textbox and select whatever target you want to have built. In the example above, I have selected the target <menuchoice>all</menuchoice> from project '''''1.deal.II''''' and '''''step-32''''' from project '''''1.step-32''''' to make sure both the base library and the application program have been compiled and are up to date before the program is actually executed. While you're there, you may as well also configure a debug launch by clicking on the <menuchoice>Debug</menuchoice> symbol and adding the name of the debugger program; if this is the system's default debugger (e.g. '''gdb''' on Linux), then you don't need to do this step.
*  Select <menuchoice>Run -> Configure launches</menuchoice> from the menubar.
*  Highlight the project you want to add a launch for and click on the {{Plus}}/<menuchoice>Add</menuchoice> button.
*  From the drop down menu shown, select the name of the launch configuration.
*  Enter the name you want to call the launch configuration (you can edit it later by double clicking it ).
*  In the executable tab, choose the project target or the path where you want to run the program.
Any required command line arguments can be specified in the <menuchoice>Arguments:</menuchoice> edit box.
 
<!--T:17-->
[[File:KDevelop-arguments-config.png.png|800px|thumb|center]]
 
<!--T:18-->
If you need to build the executable or add libraries before running it,add the dependencies tab at the bottom of the page,
* select <menuchoice>Build</menuchoice> from the dropdown <menuchoice>Action:</menuchoice> menu.
* Select the {{Icon|folder}} symbol to the right of the textbox and select whatever target you want to have built.
* Click Ok.
 
<!--T:19-->
To configure a debug launch:
*  Select on the <menuchoice>Debug</menuchoice> symbol under the selected launch configuration on the left tab.
*  add the path to the debugger program.
 
<!--T:20-->
if this is the system's default debugger (e.g. '''gdb''' on Linux), then you don't need to do this step.


<!--T:6-->
<!--T:6-->
[[Image:kdevelop-3.png|thumb|650px|center]]
[[File:Kdevelop-after-nano-run.png|650px|thumb|center]]


<!--T:7-->
<!--T:7-->
You can now try to run the program: Select <menuchoice>Run -> Execute Launch</menuchoice> from '''KDevelop's''' main window menu (or hit <keycap>Shift + F9</keycap>) and your program should run in a separate subwindow of '''KDevelop'''. The picture above shows the result: The new <menuchoice>Run</menuchoice> tool subwindow at the bottom shows the output of the program that is being run, in this case of the '''''step-32''''' program.
To run the program:
*  From the menu bar, select <menuchoice>Run -> Execute Launch</menuchoice>or use the shortcut <keycap>Shift + F9</keycap>.
Your program should now run in an external ''terminal window'' of '''KDevelop'''. The picture above shows the result: The new <menuchoice>Run</menuchoice> tool subwindow at the bottom shows the output of the program that is being run, in this case the '''''nano''''' text editing program.


<!--T:8-->
<!--T:8-->
{{Note|1= If you have configured multiple launches, you can choose which one should run when you hit <keycap>Shift + F9</keycap> by going to <menuchoice>Run -> Current Launch Configuration</menuchoice>. Unfortunately, by default, all launches are named ''New Native Application'' without an ''obvious'' possibility of renaming them, making it difficult to distinguish them when selecting the current launch configuration (see [https://bugs.kde.org/show_bug.cgi?id=272300 KDevelop bug 272300]). There is a non-obvious way to edit the name of a configuration, however: in the dialog box you get when you select <menuchoice>Run -> Current Launch Configuration</menuchoice>, double-click on the name of the configuration in the tree view on the left, which will allow you to edit the configuration's name.}}
{{Note|1= If you have configured multiple launches, you can choose which one should run when you hit <keycap>Shift + F9</keycap> by going to <menuchoice>Run -> Current Launch Configuration</menuchoice>. There is a non-obvious way to edit the name of a configuration, however: in the dialog box you get when you select <menuchoice>Run -> Current Launch Configuration</menuchoice>, double-click on the name of the configuration in the tree view on the left, which will allow you to edit the configuration's name.}}




Line 38: Line 62:


<!--T:14-->
<!--T:14-->
| <keycap>F8</keycap>
| style="width: 15%"|<keycap>F8</keycap>  
| Build (call make)
| style="width: 85%"|Build (call make)
|-
|-


<!--T:15-->
<!--T:15-->
| <keycap>Shift + F9</keycap>
| <keycap>Shift + F9</keycap>  
| Run
| Run
|-
|-


<!--T:16-->
<!--T:16-->
| <keycap>F9</keycap>
| <keycap>F9</keycap>  
| Run program in the debugger; you may want to set breakpoints beforehand, for example by right-clicking with the mouse on a particular line in the source code
| Run program in the debugger; you may want to set breakpoints beforehand, for example by right-clicking with the mouse on a particular line in the source code
|-


</translate>|}<translate>
</translate>|}<translate>

Latest revision as of 04:48, 27 August 2020

Other languages:

Running programs in KDevelop

Once you have built a program, you will want to run it. To do this, need to configure Launches for your project. A Launch consists of the name of an executable, a set of command line parameters, and an execution environment (such as "run this program in an external terminal", or "run this program in the debugger").

Setting up launches in KDevelop

  • Select Run -> Configure launches from the menubar.
  • Highlight the project you want to add a launch for and click on the /Add button.
  • From the drop down menu shown, select the name of the launch configuration.
  • Enter the name you want to call the launch configuration (you can edit it later by double clicking it ).
  • In the executable tab, choose the project target or the path where you want to run the program.

Any required command line arguments can be specified in the Arguments: edit box.

If you need to build the executable or add libraries before running it,add the dependencies tab at the bottom of the page,

  • select Build from the dropdown Action: menu.
  • Select the symbol to the right of the textbox and select whatever target you want to have built.
  • Click Ok.

To configure a debug launch:

  • Select on the Debug symbol under the selected launch configuration on the left tab.
  • add the path to the debugger program.

if this is the system's default debugger (e.g. gdb on Linux), then you don't need to do this step.

To run the program:

  • From the menu bar, select Run -> Execute Launchor use the shortcut Shift + F9.

Your program should now run in an external terminal window of KDevelop. The picture above shows the result: The new Run tool subwindow at the bottom shows the output of the program that is being run, in this case the nano text editing program.

Note
If you have configured multiple launches, you can choose which one should run when you hit Shift + F9 by going to Run -> Current Launch Configuration. There is a non-obvious way to edit the name of a configuration, however: in the dialog box you get when you select Run -> Current Launch Configuration, double-click on the name of the configuration in the tree view on the left, which will allow you to edit the configuration's name.


Some useful keyboard shortcuts

Running a program
F8 Build (call make)
Shift + F9 Run
F9 Run program in the debugger; you may want to set breakpoints beforehand, for example by right-clicking with the mouse on a particular line in the source code