2

Im running Mac OS X 10.8 (Mountain Lion) with xCode 4.5.1 with command line tools.

I have just installed GNAT 2012 from here.

I installed it using this tutorial:

Navigate to the directory that contains a file called: doinstall
Enter: sudo mkdir /usr/loca/gnat You will have to enter your password
Enter: sudo ./doinstall Press return and y as prompted Update your path: sudo export PATH=/usr/local/gnat/bin:$PATH You should now be able to compile using the command gnatmake

Everything went fine and I restarted. In my desktop I have hello.adb:

with Ada.Text_IO;use Ada.Text_IO;
procedure Hello is
begin
    Put_Line ("Hello world!");
end Hello;

And in terminal I navigate to my desktop and execute the gnatmake hello.adb. But I get this

-bash: gnatmake: command not found

But in terminal If I execute info gnat I get a very large documentation.

  1. Why cant I compile hello.adb? Anyway to fix?
  2. Can I create ada projects and compile/debug within xCode? I would like to edit the source files using xCode as the IDE. If so what type of project shall I use? "external build system" perhaps? Could somebody please post a tutorial on how to run a hello world using xcode? It would help me a lot. Video would be great. such a pity that Ada has so little resources on the internet.
Giacomo1968
  • 25,759
  • 11
  • 71
  • 103

1 Answers1

3

You need to put the path to Ada in a more permanent place. The command you entered in your Terminal only lasts for as long as the terminal is open.

Open ~/.bash_profile and add

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

You can open the file from Terminal with either

nano ~/.bashrc

or

vim ~/.bashrc

If you're using ZSH, place the export line in ~/.zshrc.

EDIT: For #2, I can't find an updated XCode plugin, but if you want an IDE, check out this top answer.

Community
  • 1
  • 1
jmdeldin
  • 5,354
  • 1
  • 28
  • 21
  • Yeyy! You are awesome! just one questions: When I gnatmake hello.adb it creates 2 other files. How can I run hello.adb in the same terminal window? Right now I have to double click on it and it opens in another terminal window which has a white bg. –  Oct 17 '12 at 00:01
  • @Alex90: I think you can just run `./hello`, where "hello" is whatever executable file you double-click to run. Does that do it? – jmdeldin Oct 17 '12 at 00:16
  • yes. I needed to have "./" before the file name. You made my day! Have a nice day you too. –  Oct 17 '12 at 00:29
  • Great, glad you're up and running. Enjoy Ada Lovelace Day! – jmdeldin Oct 17 '12 at 00:32