Search code examples
macoscompilationadagnat

Learning simple Ada, getting GNAT compiling error in OS X


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!


Solution

  • 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.