This chapter presents the steps needed to install the GNAT Community toolchain and how to use basic commands from the toolchain.
These are the basics steps to install GNAT Community on all platforms:
Go to the AdaCore Community page.
Download the GNAT installer.
Run the GNAT installer.
- Leave all options checked on the "Select Components" page.
On Windows platforms, continue with the following steps:
- The environment variables can be found in the
System Propertieswindow of the
You might need to restart your computer for the settings to take effect.
On Linux platforms, perform the following steps:
Make sure the GNAT installer has execution permissions before running it.
Select the directory where you want to install the toolchain.
- For example:
Add the path to the
bindirectory (within the toolchain directory) as the first directory in your
- For example:
Now that the toolchain is installed, you can start using it. From the command line, you can compile a project using gprbuild. For example:
gprbuild -P project.gpr
You can find the binary built with the command above in the obj directory. You can the run it in the same way as you would do with any other executable on your platform. For example:
A handy command-line option for gprbuild you might want to use
-p, which automatically creates directories such as
obj if they
aren't in the directory tree:
gprbuild -p -P project.gpr
Ada source-code are stored in .ads and .adb files. To view the content of these files, you can use the GNAT Programming Studio (GPS). To open GPS, double-click on the .gpr project file or invoke GPS on the command line:
gps -P project.gpr
To compile your project using GPS, use the top-level menu to
main.adb (or press the
F4). To run the main program, click on
main (or press the keyboard shortcut
Shift + F2).