Ada/Setting up the compiler

From Wikiversity
< Ada
(Redirected from Setting up the compiler)
Jump to navigation Jump to search

Overview[edit | edit source]

Before we begin programming we need to get and install an Ada compiler. Before we do that we need to install Linux as our operating system. We will be using GNAT and Emacs for this course.

Goals:[edit | edit source]

  1. Install Linux
  2. Install the GNAT compiler
  3. Install the Emacs editor

Installing Linux[edit | edit source]

For this course we will use Ubuntu Linux, which is a popular flavor of Linux for most newcomers to the system. Ubuntu can be download directly from the Ubuntu website. If you are a Windows user and you prefer to keep your Windows system and files, you will need to either create a dual-boot system (which can be somewhat complicated) or download and install some kind of virtualization software, like VirtualBox. This section deals with installing Ubuntu with VirtualBox on a Windows system. If you happen to have a spare computer then you can use that install Linux on without downloading VirtualBox. It's a matter of preference what you decide to do.

Note: It is recommended by the author that you have a dual core processor with at least 2GB of RAM to run a virtual machine.

First, install VirtualBox. This is a pretty straightforward and simple process. Once that is done you may need to restart your computer.


To install Ubuntu we need to follow these steps:

  1. Run VirtualBox
  2. Click "Machine > New" (this brings up the "New Virtual Machine" wizard)
  3. Click "Next"
  4. Give the virtual machine a name. Select "Linux" from the "Operating System" selection box. Select "Ubuntu" from the "Version" selection box. Click "Next"
  5. Select how much RAM you want the virtual machine to use. You can use the default memory allocation, which is typically 1/8 of your total system memory, but I would use at least 1/4 of memory allocation just to be safe. So if you have 4GB of RAM in your computer, 1GB of memory allocation for Ubuntu is enough. If you have 2GB, 768MB is enough for the virtual machine.
  6. We now need to create a new virtual hard disk. Select "Create new hard disk" and click "Next". This brings up the "New Virtual Disk" wizard. We want "Dynamically expanding storage" with at least 20GB of hard disk space. Click "Finish" when you are done with the hard disk size.
  7. Click "Finish" and you should see the virtual machine name appear in the list on the left side of the program in the white area.


Now that we have our virtualization software and virtual machine "hardware" figured out, we can now install Ubuntu. To do so, follow these steps:

  1. Start the virtual machine
  2. Select the ISO image containing the Ubuntu system using the first time start wizard
  3. When Ubuntu loads it's CD/DVD menu, do not load the live system. Instead, just install Ubuntu
  4. Follow all the prompts during the installation process. You want to install the system on the entire disk volume. DO NOT PARTITION THE HARD DISK!
  5. Sit back while Ubuntu installs. This is a lengthy process, so you can do some other things while that's going on.


Getting the Ada Development Tools[edit | edit source]

You may need to let Ubuntu update itself before performing these next steps.

First, we need to open the terminal.Start Ubuntu and click "Applications > Accessories > Terminal" to do this. Now type:

sudo apt-get install gnat

This will retrieve and build the GNAT compiler, which is the compiler we will need to build our own Ada files. It will also download and install several other packages that are needed.

Now we need to download the Emacs editor. You can use whatever you feel like, but Emacs has syntax highlighting and you can compile your Ada code directly inside the editor. To get Emacs type the following in the terminal:

sudo apt-get install emacs

This should be all you need to get started with basic Ada programming for now.