Up: Compilation/Build


9.1 The Build Menu

The build menu gives access to capabilities related to checking, parsing and compiling files, as well as creating and running executables.

Check Syntax
Check the syntax of the current source file. Display an error message in the Messages window if no file is currently selected.
Compile File
Compile the current file. Display an error message in the Messages window if no file is selected.

If errors or warnings occur during the compilation, the corresponding locations will appear in the Locations Tree. If the corresponding Preference is set, the source lines will be highlighted in the editors (see The Preferences Dialog). To remove the highlighting on these lines, remove the files from the Locations Tree.

Make
Compile all sources
Compile all source files defined in the currently selected project, or by default the top level project.
All
Build and link all main units defined in your project. If no main unit is specified in your project, build all files defined in your project and subprojects recursively. For a library project file, compile sources and recreate the library when needed.
<current file>
Consider the currently selected file as a main file, and build it.
Custom...
Display a text entry where you can enter any external command. This menu is very useful when you already have existing build scripts, make files, ... and want to invoke them from GPS. If the SHELL environment variable is defined (to e.g. /bin/sh), then the syntax used to execute the command is the one for this shell. Otherwise, the command will be spawned directly by GPS without any shell interpretation.

Clean
Root Project
Remove all object files and other compilation artifacts associated to the root project. It does not clean objects from other related projects.
all
Remove all object files and other compilation artifacts associated to all projects related to the current one. It allows to restart a complete build from scratch.

Recompute C/C++ Xref info
Recompute the cross-reference information for C and C++ source files. See Support for Cross-References.
Load xref info in meomry
Load all the cross-reference information in memory. This menu is generally not needed, See Support for Cross-References.
Run
main
For each main source file defined in your top level project, an entry is listed to run the executable associated with this main file. Running an application will first open a dialog where you can specify command line arguments to your application, if needed. You can also specify whether the application should be run within GPS (the default), or using an external terminal.

When running an application from GPS, a new execution window is added in the bottom area where input and output of the application is handled. This window is never closed automatically, even when the application terminates, so that you can still have access to the application's output. If you explicitly close an execution window while an application is still running, a dialog window will be displayed to confirm whether the application should be terminated.

When using an external terminal, GPS launches an external terminal utility that will take care of the execution and input/output of your application. This external utility can be configured in the preferences dialog (External Commands->Execute command).

The GPS execution windows have several limitations compared to external terminals. In particular, they do not handle signals like <ctrl-z> and <control-c>. In general, if you are running an interactive application, we strongly encourage you to run in an external terminal.

Similarly, the Run contextual menu accessible from a project entity contains the same entries.

Custom...
Similar to the entry above, except that you can run any arbitrary executable. If the SHELL environment variable is defined (to e.g. /bin/sh), then the syntax used to execute the command is the one for this shell. Otherwise, the command will be spawned directly by GPS without any shell interpretation.

The Tools->Interrupt menu can be used to interrupt the last compilation or run command. Once you have interrupted that last operation, you can interrupt the previous one by selecting the same menu again.

However, the easiest way to interrupt a specific operation, no matter if it was started last or not, is to use the Task Manager, through the Tools->Views->Tasks menu. It will show one line per running process, and right-clicking on any of these lines gives the possibility to interrupt that process.

If your application is build through a Makefile, you should probably load the Makefile.py startup script (see the menu /Tools/Plug-ins).