Ada on the Mac

Objective

The purpose of this web site is to document information you might need to know to install and run Ada code on an Apple Macintosh computer. Installing Ada is not easy; it requires a lot of what Grady Booch calls "stupid knowledge." Stupid knowledge is something you need to know, but you shouldn't need to know, to accomplish some task. This site is a work in progress, so it is not yet complete. As of 19 November 2011, I've finally successfully installed Ada, compiled, linked, and run Ada programs on my Mac, so I can start this documentation effort.

Background

Remember Turbo Pascal? It was trivial to install and use and I spent less than $50 for it. Why doesn't someone sell a similar product for Ada?

I originally intended to install GNAT and use it from the Mac Unix command line interface (CLI). There are no free or inexpensive development environments for the Macintosh, but I can do CLI; that's all we had 35 years ago. However, I can't even get started with the installation. I've tried several installers, but none produce a GNAT installation that works. I've done internet research and posted questions on message boards, but what I learn is cryptic (lots of Unix techno-babble), doesn't help, and each bit of information probably gives me only 2% of everything that I need to know. Don't bother with GNAT for Macintosh. None of those downloads work. They might with liberal application of much stupid knowledge, which I do not have. That page hasn't changed in many years.

So in frustration I finally gave in and went where I didn't want to go. Windows. There are several reasons for using Windows. I am able to use GNAT Ada on an actual Windows computer for which I have limited acces. It's easier to solve a problem if you know for certain that there is a solution. So I have an example of an installation that works. Additionally, there is a lot more support for GNAT in a Windows environment. So my first success was with Windows and the following paragraphs will provide some instruction for installing GNAT in Windows on a Mac.

GNAT in Windows for Mac

You could probably use the built in Boot Camp capability in OS X to run Windows. But with Boot Camp you are either all OS X or all Windows. I don't like that approach; I want to use all of the Mac capability at the same time that I'm doing Ada development. Parallels Desktop. I highly recommend Parallels Desktop. Parallels seamlessly integrates OS X and Windows. It does it so well, that you hardly notice that Windows is there; it gives Windows a Macintosh interface. They call it the "coherence" mode. (Be sure to install 64-bit Windows as the 32-bit version doesn't seem to support coherence mode.) I could say many more great things about Parallels, but just go to the website and read about its features. (Perhaps I should sing the praises of Parallels because their website understates the features and undersells the product.) I've successfully installed Ada on my Mac using Parallels and Windows 7. You need four things:

  • Parallels Desktop
  • Microsoft Windows
  • GNAT
  • AdaGIDE

Do not purchase Windows from the Microsoft web site. You might think you can get it at a bargain price because the shopping page lists the price as "from $119.99", but if you click the link to purchase it, the price becomes $199.99. Additionally, if you download Windows 7 from the Microsoft website you get an .exe file and a couple .box files. Parallels cannot install Windows from these files. The best approach is to purchase Windows from Parallels. When you install Parallels on your Mac the installer will offer you the opportunity to Purchase Windows from the Parallels website and if you purchase it from Parallels, the Parallels installer will download and install Windows into your virtual Windows machine automatically. (Parallels allows you to create more than a single virtual Windows machine.)

You've got Parallels and Windows. Now you need GNAT Ada. You can get GNAT at AdaCore. Click the GNAT GPL download button, choose the x86-windows platform, and choose GNAT_GPL. (You may or may not need win32ada. I needed it, so I grabbed that as well.) You will need to have a Parallels virtual Windows machine running to install GNAT.

Finally, you will want a development environment. At this point you could probably use Ada with the CLI, but it's much easier to use a development tool. AdaGIDE is a simple and easy to use environment for writing, compiling, linking, and running Ada code. You can download AdaGIDE from Dr. Martin C. Carlisle's The New AdaGIDE Home Page. (Click the sourceforge site link.) You need to download this from within Windows so that you get the .exe installer. If you download it from OS X, you just get the files and you won't know where to put them. After installing AdaGIDE I worried about how AdaGIDE would find where GNAT is. However, that happened automagically. I haven't found any documentation for AdaGIDE. You will need to know something about the GNAT compiler and linker (make) switches to use AdaGIDE effectively.

GPS (GNAT Programming Studio) comes with the GNAT download. I was able to compile, link, and run Ada code with GPS also. You will need to learn how to build a "project file" to use GPS. GPS is more powerful than AdaGIDE, but I haven't used it much because it tends to be a display screen real estate hog—it presents a myriad of windows, most of which I don't understand. It's a problem on a small monitor, but I might learn to like it on my 27 inch iMac screen.

Initially, the Mac won't know what to do with the Ada .ads and .adb files. So the first time you open one, right click on the icon, select "Open With"/"Other..." and then find the adagide.exe.app application in the "Choose Application" dialog box. I can't tell you where it is—you'll have to find it yourself. Every time I install AdaGIDE it ends up in a different place. (Don't bother to wonder why; this is the wacky world of Windows.) Then before clicking the open button, check the "Always Open With" checkbox. After doing this you only need to double click the Ada files to open them in AdaGIDE.

After following the steps in the previous paragraphs, I have successfully installed Parallels, Windows 7, GNAT, and AdaGIDE on my Mac and I have successfully compiled, linked, and run several Ada programs using both AdaGIDE and GPS.

Parallels is great, but there are some things about it that you will find frustrating. If you have more than one virtual machine built and things are acting strangely check to make sure you are actually using the virtual machine that you think you are using. It is not sufficient to turn off a virtual machine that you don't want to use. Parallels will sometimes turn on a virtual machine if it thinks the application you want to run is on that machine. This confused me for a whole day until I figured out what was going on.

Future Problems to Solve

Though I've compiled an run a few small Ada programs, I was unable to compile an 83,000 line flight dynamics simulation program with GNAT 2011, GNAT 2010, GNAT 2009, or GNAT 2007. I managed to find an old copy of GNAT 2005 and it compiles with that.

In AdaGIDE, if I compile, link, and run a program and then try to compile it again I get an error message: "Unable to start compiler. Check path environment variable. Error code 267." The same thing happens with the installation I have used on an actual Windows computer. The workaround is to quit AdaGIDE and the open it again. It is very annoying. If anyone knows how to fix this, please let me know.

Within Windows applications, I have visibility to only the Mac boot partition and the Windows "C:" drive that is created by the virtual machine. I'm not able to get to my other mounted volumes. I would like to move all my Ada code from the boot partition to my data partition. If anyone knows how to fix this in Parallels, please contact me.

Eventually, I'd like to return to my original quest—to install GNAT without using Windows. I worry that the Ada executables run slower in the virtual Windows machine than they would in OS X.

Resources & References

Contact

Alternity@sbcglobal.net