Next: Compiler errors, Up: Compiling Executing [Contents][Index]

### 4.1 Compile commands

Here are the commands for building and using an Ada project, as listed in the Ada menu.

In multi-file projects, there must be one file that is the main program. That is given by the `main` project file variable; it defaults to the current file if not yet set, but is also set by the “set main and build” command.

`Check file`

  Compiles the current file in syntax check mode, by running `check_cmd` defined in the current project file. This typically runs faster than full compile mode, speeding up finding and fixing compilation errors.

  This sets `main` only if it has not been set yet.

`Compile file`

  Compiles the current file, by running `comp_cmd` from the current project file.

  This does not set `main`.

`Set main and Build`

  Sets `main` to the current file, then executes the Build command.

`Show main`

  Display `main` in the message buffer.

`Build`

  Compiles all obsolete units of the current `main`, and links `main`, by running `make_cmd` from the current project.

  This sets `main` only if it has not been set yet.

`Run`

  Executes the main program in a shell, displayed in a separate Emacs buffer. This runs `run_cmd` from the current project. The execution buffer allows for interactive input/output.

  To modify the run command, in particular to provide or change the command line arguments, type `C-u` before invoking the command.

  This command is not available for a cross-compilation toolchain.

It is important when using these commands to understand how `main` is used and changed.

Build runs ’gnatmake’ on the main unit. During a typical edit/compile session, this is the only command you need to invoke, which is why it is bound to `C-c C-c`. It will compile all files needed by the main unit, and display compilation errors in any of them.

Note that Build can be invoked from any Ada buffer; typically you will be fixing errors in files other than the main, but you don’t have to switch back to the main to invoke the compiler again.

Novices and students typically work on single-file Ada projects. In this case, `C-c C-m` will normally be the only command needed; it will build the current file, rather than the last-built main.

There are three ways to change `main`:

1. Invoke ‘`Ada | Set main and Build`’, which sets `main` to the current file.
2. Invoke ‘`Ada | Project | Edit`’, edit `main` and `main`, and click ‘`[save]`’
3. Invoke ‘`Ada | Project | Load`’, and load a project file that specifies `main`

Next: Compiler errors, Up: Compiling Executing [Contents][Index]