Discussion:
how do you compile and run ... (hello world)
(too old to reply)
g***@gmail.com
2014-08-23 13:54:01 UTC
Permalink
i have downloaded gnat gpl edition from libre.adacore.com

i have installed gnat. it is located /usr/local/gnat/

i have created a file called hello.adb, found in ADA95 textbook,

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

i have cd into /usr/local/gnat/bin
typed: gnat

and got this

GNAT GPL 2014 (20140331)
Copyright 1996-2014, Free Software Foundation, Inc.

List of available commands

gnat bind gnatbind
gnat chop gnatchop
gnat clean gnatclean
gnat compile gnatmake -f -u -c
gnat check gnatcheck
gnat elim gnatelim
gnat find gnatfind
gnat krunch gnatkr
gnat link gnatlink
gnat list gnatls
gnat make gnatmake
gnat metric gnatmetric
gnat name gnatname
gnat preprocess gnatprep
gnat pretty gnatpp
gnat stack gnatstack
gnat stub gnatstub
gnat test gnattest
gnat xref gnatxref

All commands except chop, krunch and preprocess accept project file switches -vPx, -Pprj and -Xnam=val

i then cd back into my home dir : cd ~
where the hello.adb file is located

i entered: gnat compile hello.adb

i got back:

gcc -c hello.adb

in the directory i see:

hello.adb
hello.ali
hello.c.save
hello.o

what do i need to do to run the program ... and compile if i have done something wrong?
Dmitry A. Kazakov
2014-08-23 14:19:38 UTC
Permalink
Post by g***@gmail.com
hello.adb
hello.ali
hello.c.save
hello.o
what do i need to do to run the program ... and compile if i have done something wrong?
$ gnatmake hello.adb

This [re]compiles, binds and links as necessary.
--
Regards,
Dmitry A. Kazakov
http://www.dmitry-kazakov.de
g***@gmail.com
2014-08-23 17:57:29 UTC
Permalink
Post by Dmitry A. Kazakov
$ gnatmake hello.adb
This [re]compiles, binds and links as necessary.
--
Regards,
Dmitry A. Kazakov
http://www.dmitry-kazakov.de
Thank-you,

g.
Jeffrey Carter
2014-08-23 17:56:25 UTC
Permalink
Post by g***@gmail.com
what do i need to do to run the program ... and compile if i have done something wrong?
You might find it useful to read the top-secret GNAT documentation.

http://docs.adacore.com/gnat-unw-docs/html/gnat_ugn.html
--
Jeff Carter
"I feel as though somebody stepped on my tongue
with muddy feet."
Never Give a Sucker an Even Break
112
g***@gmail.com
2014-08-23 18:14:22 UTC
Permalink
Post by Jeffrey Carter
You might find it useful to read the top-secret GNAT documentation.
http://docs.adacore.com/gnat-unw-docs/html/gnat_ugn.html
--
Jeff Carter
actually i should have read past

You can compile the program using the following command ($ is used as the command prompt in the examples in this document):


$ gcc -c hello.adb

gcc is the command used to run the compiler. This compiler is capable of compiling programs in several languages, including Ada and C. It assumes that you have given it an Ada program if the file extension is either `.ads' or `.adb', and it will then call the GNAT compiler to compile the specified file.

because i got the following error:

error: invalid value 'ada' in '-x ada'

still do. but Dmitry answer was perfect and worked.

thanks jeff, i will try read that documentation to the end.

hey, but don't go to far though, i'm sure i will have questions.
this is day one of learning ADA.
i'm using an old book though ada 95 program solving and program design, 2ed.

thanks again,

g.

Continue reading on narkive:
Loading...