GNAT Programming Studio at VTC


Introduction

This note briefly describes how to configure a project using AdaCore's GNAT Programming Studio (GPS). This product is a full featured IDE for Ada programming with many of the usual features in modern IDEs. This note glosses over most of GPS's abilities, focusing instead on quickly getting you up to speed with compiling small to medium sized Ada programs.


Key Concepts

Like most IDE systems GPS is project based. You should put each program you write in its own project in a folder using the same name as the project. Unlike some other IDEs the command line gnatmake tool also understands the same project files as GPS. This gives you a central location for storing and managing a project's characteristics. You can switch between GPS and the command line tools as convenient without loosing any configuration information.


Setting up a GPS project

Here are the basic steps for setting up an Ada project using GPS.

  1. Start GPS. You can either pick it from the start menu of your Windows system or type gps at a suitable command prompt.

  2. You will see a welcome dialog as shown below. Select "Create new project with wizard."

    screenshot

  3. The wizard has several dialogs you can use to configure your project. All of a project's settings can, of course, be changed later from within GPS (or by manually editing the project file).

    On the left hand side of the project wizard is a list of configuration dialogs. As you progress through the wizard you will see the currently selected dialog move down the list.

    In the first dialog you select the kind of project you want to create. If you don't know the best choice, use the default. In the second dialog (shown below) you provide the name and location of your project. Type in the name of the folder where you want the project to be stored. You should use the same name for that folder as for the project. It is not necessary for the folder to exist at this point.

    screenshot

  4. You can accept the defaults on the next three dialogs. However, when you specify the build location, be sure the project folder is used. The build location is where the compiled object files for your project will be placed. The default location suggested by the wizard is often not suitable.

    screenshot

  5. In the next dialog (below) you are asked to specify which file contains the main procedure of your program. Click the "Add" button in the upper right corner to add the file. The file does not need to exist at this point; in that case you can type its name directly into the File/Open dialog box that appears. The folder in which the file is located does need to exist, however. You can create it, if necessary, using the controls on the File/Open dialog.

    screenshot

  6. You can accept the default naming convention. However, in the next dialog you will want to activate a few non-default switches on the "Ada" tab. See the screen shot below. The overflow checking and stack checking options are needed for GNAT to behave strictly according to the Ada standard. The debugging options should also be activated in case you want to debug your programs (and you probably will want this). You can also optionally select Ada 2005 mode, although that is the default behavior.

    screenshot

  7. Optionally you can also activate some reasonable warnings to help the compiler find more of your mistakes. Click on the "Warnings" button in the dialog above to get a list of warnings you can select. The screen shot below shows a recommended collection.

    screenshot

  8. On the "Ada Linker" tab of the same dialog, you should activate debugging information in the linker as well. This is shown below.

    screenshot

  9. You can now complete the wizard. GPS will create a project file (with a .gpr extension) in the folder you specified and open its main window as shown below.

    screenshot

  10. You are now ready to start programming in Ada! Create a new file and save it under the name hello.adb. Enter the program shown in the screen shot below. You can use the F4 function key to build your executable.

    screenshot


Getting Help

On the GPS help menu you have access to a number of useful documents. These include information on GPS, on the underlying GNAT compiler, the Ada reference manual that specifies the language, and some other things. Most of these items are HTML documents; selecting an item should launch your web browser on the appropriate file.


© Copyright 2007 by Peter C. Chapin.
Last Revised: December 21, 2007