How to Compile Ada Programs
This page briefly explains how to use your Ada compiler to create Ada programs.
The basic steps to commanding an Ada compiler are the same
for all Ada compilers, but the details (the exact keys you press)
vary from compiler to compiler.
The basic steps are:
Install the Ada compiler
Create a project (directory)
Create and edit file(s) containing Ada source code
Compile the source code, creating object code
Link the object code, creating a program
Run the resulting program
(Optionally) Debug the resulting program
For Ada compilation systems with graphical front-ends, every step but the
first is usually obvious from the menus.
However, if you're not using a graphical front end these steps
may not be so obvious.
Below are each of these steps, with some specific guidance for
the GNAT and Rational VADS compilers when used without a graphical front-end
(especially for MS-DOS/MS-Windows and Unix platforms).
Install the compiler.
These are very compiler-specific, but installation instructions
are included with every compiler.
Most operating systems have a ``PATH'' that must be correctly
set up as part of the installation procedures.
Create a project (directory).
Generally it's best to create a separate directory for your
In MS-DOS and Unix, the command "mkdir" may be used to create
a new directory.
Rational VADS requires that a directory for Ada files be specially
prepared; use the "a.mklib" command to do this.
Create and edit file(s) containing the Ada source code.
Use your favorite text editor to create Ada source code
files (such as emacs, vi, edit, or Brief).
No matter what compiler you're using,
use a separate file for each different compilation unit (GNAT requires this).
Rational VADS requires all Ada filenames to end with ".a";
I suggest naming files in the form hello_spec.a and hello_body.a.
GNAT is very picky about filenames.
Filenames must have the same name as the compilation unit before the period.
Also, filenames must end in ".ads" if they are specifications and ".adb" if
they are bodies.
Rational VADS' compilation command is "ada FILENAME"
GNAT's compilation command is "gcc -c FILENAME"
Rational VADS' link command is:
ada -M main_program_name -o object_file_name
GNAT's compilation command is:
gnatbl -o object_file_name main_program_name.ali
This is generally done by typing in the name of the object file created.
Rational VADS' debugger is called "a.db".
GNAT's debugger is the normal gcc debugger "gdb".
Hopefully, at this point you can compile simple programs
using your compiler.
The best way to learn how to use your compiler is to read its
introductory documentation; the information presented
here is simply to help you get started.
If you're connected to the Internet, you can use
to compile small Ada programs.
- Go to section 1.3.
- Go up to the Lovelace home page.
This page was last modified on 1-February-1995.
David A. Wheeler (firstname.lastname@example.org)