1

Sup all!

Glad to have found my way here hoping to receive some guidance in new chartered territory. I wanna learn Ada so I've installed EMACS and GNAT. I use a mac so it's all for OS X.

The problem is once I've written even the simplest of Ada procedures and saved them I get gnatmake compiling errors after gcc -c in bash. It's textbook examples so theres nothing wrong with my code making me believe its the way Ive set up GNAT.

UPDATE: Here's what it says in bash literally. "gnatmake: "test.adb" compilation error" straight after gcc -c test.adb. If I type gcc -c test.adb instead of gnatmake test I get "error: invalid value 'ada' in '-x ada'.

I read in one response I need to configure GNAT to my PATH (Ada compiler GNAT on Mac OS), what does that mean? Honestly I dont even know where GNAT goes after Ive "installed" it. Im so used to windows and here is an app in OSX that just installs without an EXE.

Please help me out!

  • If you get compile errors from gnatmake, gnat should be installed correctly. How about you update the question with the actual error messages? – egilhh Dec 19 '18 at 08:43
  • Thanks for your input. As for the message it just says "gnatmake: "test.adb" compilation error" straight after gcc -c test.adb. If I type gcc -c test.adb instead of gnatmake test I get "error: invalid value 'ada' in '-x ada'. Shine a light? – Gustav Agrell Dec 19 '18 at 08:56
  • Hmm... that doesn't make sense. Can you paste in the contents of the file as well? – egilhh Dec 19 '18 at 09:24
  • Im not sure what file youre refering to. My simple test code is: with Ada.Text_IO; use Ada.Text_IO; procedure Test is begin Put_Line("Sup all"); end Test; Nothing crazy, I test it at https://learn.adacore.com/ too and it works. I read OS X has no inate ada compiler so you need to PATH the gnat. Do you know what that means? – Gustav Agrell Dec 19 '18 at 09:32
  • Take a look at this [answer](https://stackoverflow.com/a/14568416/1568010) – egilhh Dec 19 '18 at 09:37
  • thanks for the pointer. Im having trouble with this step tho: "cd gnat-...-bin" it doesnt load, the file cant be found by bash even tho its unpacked in the downloads folder. it says no such file or directory. I learned how to edit the bash profile but without the install step it wont help me I guess – Gustav Agrell Dec 19 '18 at 10:39
  • When you have executed "tar zxvf ~/Downloads/gnat-gpl-2012-x86_64-apple-darwin10.8.0-bin.tar.gz" a directory "gnat-...-bin" has been created. It should be possible to enter that directory with the cd command in bash. If the directory has not been created it means unpacking the tar.gz-file failed. – Joakim Strandberg Dec 19 '18 at 14:10
  • Also consider using gprbuild instead of gnatmake. It is my understanding that gnatmake has been obsolete for many years now in favor of gprbuild, but gnatmake apparently still works. – Joakim Strandberg Dec 19 '18 at 14:17
  • As @egilhh said, *please* edit the **question** and paste **the actual error messages** in. It’s very hard to make sense of them in comments. – Simon Wright Dec 19 '18 at 17:49
  • @JoakimStrandberg, gprbuild is much more capable but harder to set up properly, especially for someone at the "hello world" stage! – Simon Wright Dec 19 '18 at 17:51
  • Thanks for your responses. In response to Joakim Strandberg. When I download gnat from AdaCore I get a .dmg file not a .tar.gz. Even if I open it and extract the .bin inside and put it in the directory, say, /downloads, I still cannot enter it with CD from bash. It says there is no such file or directory. – Gustav Agrell Dec 19 '18 at 18:06
  • @JoakimStrandberg: Regarding the status of `gnatmake`, [Gem #65](https://www.adacore.com/gems/gem-65) suggests that `gprbuild` "is also a builder, reusing and extending `gnatmake` to support multilanguage applications." – trashgod Dec 19 '18 at 18:32
  • @trashgod: I can't say what has been reused or not from gnatmake in gprbuild but I was at the AdaCore Tech Days in Paris this year and it was mentioned that gprbuild is being completely re-written. But I guess that we as users won't notice that. – Joakim Strandberg Dec 20 '18 at 11:43
  • 1
    @GustavAgrell: Right, with the latest version of the GNAT Community Edition installation has become more user friendly as Simon has outlined in his detailed response below. – Joakim Strandberg Dec 20 '18 at 11:45

1 Answers1

4

I’d forgotten that AdaCore have changed their Mac distribution method for GNAT CE 2018 to something more Mac-like.

When you double-click on the .dmg file you get this:

contents of disk image

and when you double-click on the GNAT icon (actually, for security reasons, you’ll probably need to right-button on the icon & select 'Open') you get this:

start of install dialog

and then you’re in a pretty standard installation dialog. At one point it asks where you want to install the software: I can’t say what the default will be on your machine (I think it’s remembering previous choices of mine), but I’d expect something like /usr/local/GNAT/2018; or maybe /Users/gustav/opt/GNAT/2018. Whatever, call that prefix.

All the executables will be in the bin subdirectory, so you’ll need to include <prefix>/bin at the start of your PATH. I’d very much expect the installation process to include some suggestions as to how to do this; or you could look here.

Simon Wright
  • 25,108
  • 2
  • 35
  • 62
  • Thanks for your answer Simon! :) After a holiday of ease I managed to pull myself together to get going with ada again and I realized Im back to where I started. The installation looks exactly like the one youve described and more exactly it wants to directorize at: /Users/gustavagrell/opt/GNAT/2018. So I terminal: "touch ~/.bash_profile; open ~/.bash_profile". This opens my bash profile in text editor looking like this: "export PATH=$PATH:/opt/local/bin:/usr/local/gnat/bin" What do I need write here in order for the terminal to access gnatmake? Happy New Year! – Gustav Agrell Jan 02 '19 at 19:18
  • To clarify, what I dont get is where are you pointing when you say "at the start of your PATH" . Im assuming you mean = "Users/gustavagrell/opt/GNAT/2018" in the bash profle. But where does it go? – Gustav Agrell Jan 02 '19 at 19:24
  • `export PATH=Users/gustavagrell/opt/GNAT/2018/bin:$PATH:/opt/local/bin` - I have no idea how you got `/usr/local/gnat/bin` at the end there! – Simon Wright Jan 02 '19 at 20:14
  • Clearly that should say, all on one line, `export PATH=/Users/gustavagrell/opt/GNAT/2018/bin:$PATH:/opt/local/bin` - note the `/` in the leading `/Users` – Simon Wright Feb 10 '19 at 20:05