As a Computer Engineering student, this year I had to program at Ada. And my surprise has been, especially because Ada is a language still quite well known, that there is very little documentation about this language.
Many of my colleagues who use GNU / Linux have ended up using a Windows virtual machine to “not complicate their lives”, but in reality, compiling Ada on GNU / Linux it is very easy. That’s why in this article we want to teach you how to do it step by step. The purpose of this article is to teach you how to compile Ada on our Ubuntu, something that for the information we find on the internet, seems like a complicated task.
Ada is a programming language quite old, So your documentation has become a bit obsolete. You can check for yourself that if you search Google for how to compile Ada on GNU / Linux, very little information comes out. However, as we mentioned, compiling Ada is as easy as installing it GNAT compiler, Which is part of the GNU Compiler Collection.
All you have to do is run the following in the Terminal:
sudo apt-get install GNAT-4.4
And that’s it, we can compile Ada on our Ubuntu. So easy.
However, if we want to have GNAT-GPS, the GNAT Development Environment, We must install by running the following:
sudo apt-get install GNAT-gps
Once installed, we will already have an IDE like the one in the image that heads this article.
As you can see, there is two ways to compile Ada on Ubuntu, from the IDE itself, Via the “Build All” button, or using another text editor (such as Vim) and compile from the terminal.
Personally I prefer to do it the second way, because with a single command you can compile an entire project. And is that, so to speak, with Gnat it is enough that we compile the main program, And is already in charge of looking for all the packages we are using in our project.
For example, if we have a program called main.adb using other packages (other .ads and .adb), just make use of Gnatmake, as follows:
And then run the output file with:
As you can see, compiling Ada on Ubuntu is very simple. The truth is that as I mentioned earlier, there is quite a bit of information on the internet, so at first it may seem that compiling Ada on GNU / Linux is a tedious or difficult job, but nothing could be further from the truth. a simple command we can compile an entire project, and if we are more of IDE, as we also have one at our disposal.
We hope the article has helped you 😉