Running Ada program in linux terminal

I am using Mint Linux. Installed gnat for working with Ada programs using "sudo apt-get install gnat".
created a simple welcome program:

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

and saved it as "hello.adb"

I tried to start it from the place where it was saved, opened the terminal and dialed and received the following:

$ cd / media / disk1 / ada \ programs
$ gnatmake hello.adb
gcc-4.4 -c hello.adb
gnatbind -x hello.ali
gnatlink hello.ali
$ hello
The 'hello' program can be found in the following packages:
* hello
* hello-debhelper
Try: sudo apt-get install
$. / hello
bash: ./ hello: Permission denied

What should I do to see the program exit?
where is it not?

Several sites said to just type β€œhi” after β€œgnatmake hello.adb,” but that didn't work,
and few said try "./hello" after "gnatmake hello.adb", but that didn't work either?

what's next? help pls ..

+4
source share
3 answers

Do not build the /media/disk1/ada\ programs directory in which you (apparently) do not have adequate permission . Instead, create somewhere in your home directory ~ where you have permission. GNAT executables are usually installed in /usr/bin , which is probably already in your PATH .

  $ which gnatmake
 / usr / bin / gnatmake
 $ echo $ PATH
 / usr / local / sbin: / usr / local / bin: / usr / sbin: / usr / bin: / sbin: / bin
 $ cd ~
 $ gnatmake hello
 gcc-4.6 -c hello.adb
 gnatbind -x hello.ali
 gnatlink hello.ali
 $ ./hello 
 Hello world!
+6
source

The compilation process is fine. As Mark C says, you usually don't need to worry about permission to execute (the chmod ). GNAT must take care of this.

To run your program, you cannot just type hello . This is a new program: you just made it, and in fact your terminal is too dumb to understand what you mean. You must tell him where your program is located in the file system. This is the ./hello entry ./hello . Basically, this means "look for a program called hello in the current directory." Therefore, it will not work if you move to another directory.

+3
source

You must assign execution permission to your executable file:

 $ chmod a+x hello 

and run it:

 $ ./hello 
+2
source

All Articles