Monday, February 22, 2010

Compiling Ada with gcc

One of my students wanted to to compile Ada  on ubuntu for a project he is working with. He came to me for help. But Ada is like chinese to me. How ever I  managed to compile a simple hello world progam. as below on Ubuntu 9.04

Install GNAT (GNU New York University Ada Translator):
Code:

sudo apt-get install gnat

Here is the hello.adb

with Ada.Text_IO;

procedure Hello is
begin
   Ada.Text_IO.Put_Line("Hello, world!");
end Hello;

And use this command to compile:

$ gnat make hello.adb

You will get hello.ali and a binary hello in your home directory.

Alternately you can split the steps 

1. Run gcc to compile to object file:
Code:

gcc -c hello.adb

2. Run gnatbind to produce binder output:


gnatbind hello.ali

3. Run gnatlink to link and produce executable output:


gnatlink hello

No comments: