Gnat for Mac Ada programming
Asked Answered
I

3

9

I'm learning Ada 95 in my programming class, and I would like to install the gnat compiler on my MacBook. I have no clue as to where to get a good gnat to compile my code, and how to install it.

I currently have gedit as my text editor, because that's what we're using in our lab environment. I'm new to the Mac world so any help would be greatly appreciated.

Issy answered 28/1, 2013 at 16:47 Comment(5)
Google is usually a great place to start. This might help: adrianhoe.com/adrianhoe/2007/10/04/…Craniometer
Curious where you are studying, and why Ada-95 not 2005 or 2012 (which will be more comfortable if you have some OOP experience)Skidproof
@BrianDrummond - If he's using Gnat, he'll have access to the newer versions too. Its possible the instructor is doing something to disallow that (eg: compiling all submissions himself with flags enforcing 95-only), but I'd be surprised.Egypt
I'm studying at Western Washington University. The professors here like to have beginning programmers go through ada 95 because its a much more stricter languageIssy
It is not stricter than Ada-2005 and certainly less strict than you can make Ada-2012 with its contract model! That being said it's certainly stricter than most non-Ada languages and IMO a better choice - not just for learning but for general programming - than most. Kudos to Western Washington!Skidproof
C
10

There's an excellent free Ada compiler for Mac OS X available from AdaCore.

You should be OK with the GNAT GPL edition. Follow the Download link - choose Free Software of Academic Development - at the bottom of the page, follow Build your Download Package.

Select your platform as x86_64-darwin, 2012. Click on GNAT 2012, then on gnat-gpl-2012-x86_64-apple-darwin10.8.0-bin.tar.gz (this contains all you'll need for the moment).

You'll also need Xcode (free with Mac OS X). Pre-Lion, this was (I think) an optional install on the installation DVD. In Lion or ML, you need to get it from the App Store (in ML it's at Categories > Developer Tools > Xcode). In ML, you also need to install the command line tools: open Xcode, then Xcode > Preferences > Downloads > Components, select Install against the Command Line Tools.

I say to install Xcode first, because the GNAT install needs it (you can tell whether the command line tools are installed by saying which make: if the answer comes back blank, they aren't installed). Anyway, for the GNAT install,

$ cd
$ tar zxvf ~/Downloads/gnat-gpl-2012-x86_64-apple-darwin10.8.0-bin.tar.gz
$ cd gnat-gpl-2012-x86_64-apple-darwin10.8.0-bin
$ sudo ./doinstall

You don't need the installer after it's finished, so you can delete it.

The defaults install GNAT under /usr/local/gnat, and you'll need to make sure that /usr/local/gnat/bin is first on your path (at any rate, ahead of /usr/bin). I'd edit ~/.bash_profile_common to add

PATH=/usr/local/gnat/bin:$PATH

but I still have trouble knowing which of the ~/.bash* files do what!

Clarify answered 28/1, 2013 at 18:14 Comment(6)
I can get as far as sudo ./doinstall but it says that the make command could not be found on your path. When i go to make my path it says that i'm wrong?Issy
I don't understand "When i go to make my path it says that i'm wrong?". Anyway, you do need Xcode to do the install; make is (so far as I can tell) one of the command line tools. Which OS are you using? What does echo $PATH say? What does sudo echo $PATH say?Clarify
I have xcode installed it was just acting weird. I did a restart and tried the whole thing again and it started working :D tyvmIssy
@SimonWright thanks for these detailed instructions. I am having trouble getting this to work, though. Would you mind taking a look at my related question?Maxim
Links have died.Tend
@Grimxn, that answer is 13 years old! Nowadays, try ada-lang.ioClarify
X
5

I have OS X Yosemite 10.10.3, and I followed the following steps.

  1. Download GNAT from this place http://libre.adacore.com/download/configurations. Choose Mac OS X as the platform.

  2. Execute the following commands on the terminal:

    1. Unzip or (tar the file downloaded from the previous step, for example, as follows:

      tar zxvf gnat-gpl-2012-x86_64-apple-darwin10.8.0-bin.tar.gz   
      

      Note: this assumes that you're in the same folder as the file you downloaded in step 1.

    2. cd gnat-gpl-2012-x86_64-apple-darwin10.8.0-bin

    3. sudo ./doinstall

  3. Edit your .bash_profile file under /Users/{YOUR_USER_NAME}/.bash_profile to also have the following line

    export PATH=$PATH:/opt/local/bin:/usr/local/gnat/bin
    
  4. Save the .bash_profile file.

  5. Open a new terminal. You should now be able to execute gnatmake.

Xylo answered 18/4, 2015 at 21:17 Comment(0)
C
4

The answers here are quite old and are no longer the best options. Command-line only development is quite a pain, especially if you're just starting with the language. The alternative, GNAT Studio IDE, is no longer supported on MacOS X, but still supported on Linux and Windows. No big loss though, since its its a bit clunky, slow and poorly integrates with MacOS.

Fortunately, there's now a VSCode plugin enabling all the major features available in GNAT Studio, such as syntax coloring, debugging and IntelliSense, along with a better overall user interface:

https://marketplace.visualstudio.com/items?itemName=AdaCore.ada

Oddly enough, it's not as well promoted as GNAT Studio. In fact, I discovered this VSCode plugin on a whim after encountering difficulty setting up my development environment. The instruction for setting up the plugin is simple. It also has the most succinct and comprehensive installation instructions for the toolchain.

Calculable answered 14/1, 2022 at 21:25 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.