Build system
Prev | Chapter 3. Usage | Next

## Build system

Geany has an integrated build system. Firstly this means that the current source file will be saved before it is processed. This is for convenience so that you don't need to keep saving small changes to the current file before building.

Secondly the output for Compile, Build and Make actions will be captured in the Compiler notebook tab of the messages window (assuming you have it visible). If there are any warnings or errors with line numbers shown in the Compiler output tab, you can double click on them and Geany will switch to the relevant source file (if it is open) and mark the line number so the problem can be corrected. Geany will also set indicators for warnings or errors with line numbers.

Depending on the current file's filetype, the Build menu will contain the following items:

- Compile

- Build

- Make all

- Make custom target

- Make object

- Execute

- Set Includes and Arguments

### Compile

The Compile command has different uses for different kinds of files.

For compilable languages such as C and C++, the Compile command is setup to compile the current source file into a binary object file.

Java source files will be compiled to class file bytecode. Interpreted languages such as Perl, Python, Ruby will compile to bytecode if the language supports it, or will run a syntax check, or failing that will run the file in its language interpreter.

### Build

For compilable languages such as C and C++, the Build command will link the current source file's equivalent object file into an executable. If the object file does not exist, the source will be compiled and linked in one step, producing just the executable binary.

Interpreted languages do not use the Build command.

### Make all

This effectively runs "make all" in the same directory as the current file.

### Note

For each of the Make commands, The Make tool path must be correctly set in the Tools tab of the Preferences dialog.

### Make custom target

This is similar to running 'Make all' but you will be prompted for the make target name to be passed to the Make tool. For example, typing 'clean' in the dialog prompt will run "make clean".

### Make object

Make object will run "make current_file.o" in the same directory as the current file, using its prefix for 'current_file'. It is useful for compiling just the current file without building the whole project.

### Execute

Execute will run the corresponding executable file, shell script or interpreted script in a terminal window. Note that the Terminal tool path must be correctly set in the Tools tab of the Preferences dialog - you can use any terminal program that runs a Bourne compatible shell and accept the "-e" command line argument to start a command.

After your program or script has finished executing, you will be prompted to press the return key. This allows you to review any text output from the program before the terminal window is closed.

### Stopping running processes

When there is a running program, the Run button in the toolbar becomes a stop button and you can stop the current action. This works by sending a signal to the process (and its child process(es)) to stop the process. The used signal is SIGQUIT.

Depending on the process you started it might occur that the process cannot be stopped. This can happen when the process creates more than one child process. Therefore stopping any make actions is not possible because make creates child processes and these child processes creates again child process. There might be some other programs which cannot be stopped correctly. Xterm is known to work properly. If you are using "Terminal" (the terminal program of Xfce), you should add the command line option "--disable-server" otherwise the started process cannot be stopped. Just add this option in the preferences dialog on the Tools tab in the terminal field.

### Set Includes and Arguments

By default the Compile and Build commands invoke the compiler and linker with only the basic arguments needed by all programs. Using Set Includes and Arguments you can add any include paths and compile flags for the compiler, any library names and paths for the linker, and any arguments you want to use when running Execute.

### Note

If you are using the Build command to compile and link in one step, you will need to set both the compiler arguments and the linker arguments in the linker command setting.

These settings are not saved when Geany is shut down. See below for how to set permanent arguments.

If you need complex settings for your build system, or several different settings, then writing a Makefile and using the Make commands is recommended.

### Indicators

Indicators are red squiggly underlines which are used to highlight errors which occured while compiling the current file. So you can easily see where your code failed to compile. To remove the indicators, just click on "Remove all indicators" in the document file menu.

If you do not like this feature, you can disable it in the preferences dialog.

### File type configuration settings

You can set the commands to run for compiling, building or executing by opening the relevant `filetypes.*` configuration file, and checking the [build_settings] section. See the section called “Filetype definition files” for more information.

Prev | Up | Next
Project Management | Home | Printing support