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 gna
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!
I have OS X Yosemite 10.10.3, and I followed the following steps.
Download GNAT from this place http://libre.adacore.com/download/configurations. Choose Mac OS X as the platform.
Execute the following commands on the terminal:
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.
cd gnat-gpl-2012-x86_64-apple-darwin10.8.0-bin
sudo ./doinstall
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
Save the .bash_profile
file.
Open a new terminal. You should now be able to execute gnatmake
.