Gnat for Mac Ada programming

情到浓时终转凉″ 提交于 2019-11-30 03:06:31

问题


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.


回答1:


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!




回答2:


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.



来源:https://stackoverflow.com/questions/14566903/gnat-for-mac-ada-programming

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!