Ada: Setup & Toolchain
Ada development needs three tools: the GNAT compiler (the GCC Ada front end), Alire (the package manager and project tool), and GPRbuild (the build engine Alire drives). This page installs all three and runs your first compiled program.
Installing the Toolchain
Windows
The simplest path is Alire itself, which can manage the toolchain:
- Download the Alire installer for Windows from alire.ada.dev and run it.
- Open a new terminal and run
alr toolchain install gnat_native gprbuild— Alire downloads and manages the compiler and build engine. - Verify with
alr --versionandgnat --version.
Linux
Most distributions ship GNAT as a package — for example apt install gnat gprbuild on Debian/Ubuntu. Then install Alire from the release page and run alr toolchain install to pin a compiler version Alire controls.
macOS
Install the Ada toolchain via Alire's macOS package or Homebrew's gnat formula, then install Alire from its GitHub releases. alr toolchain install works identically on all three platforms.
alr toolchain install anyway: Alire tracks its own compiler version per workspace, which avoids mixing incompatible outputs.
Your First Crate
Alire calls a project a crate. One command scaffolds a buildable, testable project:
# create and enter a new crate named hello_ada
alr init --bin hello_ada
cd hello_ada
alr run # builds, then executes the main unit
alr init --bin creates this layout:
hello_ada/
├── alire.toml # crate metadata: name, version, dependencies
├── hello_ada.gpr # GPRbuild project file
└── src/
└── hello_ada.adb # your main procedure
The main procedure
Open src/hello_ada.adb. Every Ada program has exactly one main subprogram; the binder links the one whose name matches the GPR main:
with Ada.Text_IO; -- import the standard text I/O unit
procedure Hello_Ada is
-- declarative part: local names go here
begin
-- statement part: executable code goes here
Ada.Text_IO.Put_Line ("Hello, Ada!");
end Hello_Ada;
Three things to notice, because every Ada unit repeats them: the with clause names a dependency; names are declared in a declarative part before begin; and the closing end repeats the unit name so mismatches are compile errors, not silent bugs. Run alr run — the output is Hello, Ada!.
GPRbuild Projects
A .gpr file tells the build engine where sources live and how to organize outputs. The generated one is minimal:
project Hello_Ada is
for Source_Dirs use ("src"); -- where .ads/.adb files live
for Object_Dir use "obj"; -- compiled intermediates
for Exec_Dir use "bin"; -- final executable
for Main use ("hello_ada.adb"); -- entry point of the program
end Hello_Ada;
GPRbuild compiles units in dependency order: if hello_ada.adb withs a package, that package's specification is compiled first — automatically, no makefile rules to maintain. For this track's single-file demos you can also invoke the compiler directly:
# compile and run a single-file demo without a project file
gnatmake demo/foundations/01_hello.adb
./01_hello
Editors and LSP
Any editor works. Two good options with real Ada support:
- VS Code with the Ada language server (ada-lang.io extension): completion, go-to-definition, and error highlighting via the free, open source ada_language_server.
- GNAT Studio, AdaCore's IDE: integrated project view, debugger, and refactoring out of the box.
Checklist
Before moving to the Syntax lesson, confirm you can:
- Run
alr --versionandgnat --versionwithout errors. - Create a crate with
alr init --binand run it withalr run. - Explain what a
.gprfile controls.