comp.lang.ada
 help / color / mirror / Atom feed
* Setting up an Ada hello world project
@ 2006-10-31 19:14 markww
  2006-10-31 19:43 ` Jeffrey R. Carter
                   ` (2 more replies)
  0 siblings, 3 replies; 8+ messages in thread
From: markww @ 2006-10-31 19:14 UTC (permalink / raw)


Hi,

I finally got a working compiler for windows. However, I'm not quite
sure how to go about compiling a hello world application. The default
project created one source file with the text:

    project Ada_LinkedList is
      for Object_Dir use "..\..\..\";
          for Main use ("main");

    end Ada_LinkedList;

but the compiler complains that there are no Ada sources in this
project. How do I go about adding an Ada source? I just want to run
something like:

    with Ada.Text_IO;

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

Where does one #include this in Ada? 

Thanks,
Mark




^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Setting up an Ada hello world project
  2006-10-31 19:14 Setting up an Ada hello world project markww
@ 2006-10-31 19:43 ` Jeffrey R. Carter
  2006-10-31 19:56   ` markww
  2006-10-31 20:58 ` Björn Persson
  2006-11-01  7:27 ` Martin Krischik
  2 siblings, 1 reply; 8+ messages in thread
From: Jeffrey R. Carter @ 2006-10-31 19:43 UTC (permalink / raw)


markww wrote:
> 
> I finally got a working compiler for windows. However, I'm not quite
> sure how to go about compiling a hello world application. The default
> project created one source file with the text:

Glad to hear it. We could answer your questions better if you told us 
what compiler you are using. Different compilers do things differently.

>     project Ada_LinkedList is
>       for Object_Dir use "..\..\..\";
>           for Main use ("main");
> 
>     end Ada_LinkedList;

This seems to be for a project called "Ada_Linkedlist" with a main 
subprogram called "Main". This is compiler-dependent.

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

This seems to be an Ada procedure called "Hello". Why you think 
something called "Ada_Linkedlist", referencing something called "Main", 
will compile something called "Hello" is not clear to me.

> Where does one #include this in Ada? 

One doesn't "#include" anything in Ada.

-- 
Jeff Carter
"Whatever it is, I'm against it."
Horse Feathers
46



^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Setting up an Ada hello world project
  2006-10-31 19:43 ` Jeffrey R. Carter
@ 2006-10-31 19:56   ` markww
  2006-10-31 20:50     ` Michael Bode
  0 siblings, 1 reply; 8+ messages in thread
From: markww @ 2006-10-31 19:56 UTC (permalink / raw)


Hi Jeff,

This is the first time I'm using Ada, sorry if my questions seem
absoultely ridiculous to you. I am using GPS - GNAT for windows. I
created a new project called 'Ada_LinkedList'. I'd just like to be able
to output something to screen, I'm not sure how what the compiler
wizard created for me combines with the hello world snippet I found to
produce an exe which will do that,

Thanks,
Mark

On Oct 31, 2:43 pm, "Jeffrey R. Carter"
<spam.not.jrcar...@acm.not.spam.org> wrote:
> markww wrote:
>
> > I finally got a working compiler for windows. However, I'm not quite
> > sure how to go about compiling a hello world application. The default
> > project created one source file with the text:Glad to hear it. We could answer your questions better if you told us
> what compiler you are using. Different compilers do things differently.
>
> >     project Ada_LinkedList is
> >       for Object_Dir use "..\..\..\";
> >           for Main use ("main");
>
> >     end Ada_LinkedList;This seems to be for a project called "Ada_Linkedlist" with a main
> subprogram called "Main". This is compiler-dependent.
>
> >     with Ada.Text_IO;
>
> >     procedure Hello is
> >     begin
> >        Ada.Text_IO.Put_Line("Hello, world!");
> >     end Hello;This seems to be an Ada procedure called "Hello". Why you think
> something called "Ada_Linkedlist", referencing something called "Main",
> will compile something called "Hello" is not clear to me.
>
> > Where does one #include this in Ada?One doesn't "#include" anything in Ada.
>
> --
> Jeff Carter
> "Whatever it is, I'm against it."
> Horse Feathers
> 46




^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Setting up an Ada hello world project
  2006-10-31 19:56   ` markww
@ 2006-10-31 20:50     ` Michael Bode
  0 siblings, 0 replies; 8+ messages in thread
From: Michael Bode @ 2006-10-31 20:50 UTC (permalink / raw)


"markww" <markww@gmail.com> writes:

> This is the first time I'm using Ada, sorry if my questions seem
> absoultely ridiculous to you. I am using GPS - GNAT for windows. I
> created a new project called 'Ada_LinkedList'. I'd just like to be able
> to output something to screen, I'm not sure how what the compiler
> wizard created for me combines with the hello world snippet I found to
> produce an exe which will do that,

I don't use GPS so I can't comment on it, but I've found that for a
start it is sometimes easier to do without IDEs and 'wizards'. Just
save this

with Ada.Text_IO;

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

to a file called 'hello.adb' and then type 'gnatmake hello.adb' on the
console.

-- 
Michael Bode



^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Setting up an Ada hello world project
  2006-10-31 19:14 Setting up an Ada hello world project markww
  2006-10-31 19:43 ` Jeffrey R. Carter
@ 2006-10-31 20:58 ` Björn Persson
  2006-10-31 21:05   ` markww
  2006-11-01  7:27 ` Martin Krischik
  2 siblings, 1 reply; 8+ messages in thread
From: Björn Persson @ 2006-10-31 20:58 UTC (permalink / raw)


markww wrote:
> I finally got a working compiler for windows. However, I'm not quite
> sure how to go about compiling a hello world application. The default
> project created one source file with the text:
[...]
> but the compiler complains that there are no Ada sources in this
> project. How do I go about adding an Ada source? I just want to run
> something like:
> 
>     with Ada.Text_IO;
> 
>     procedure Hello is
>     begin
>        Ada.Text_IO.Put_Line("Hello, world!");
>     end Hello;

You don't need a project file to compile a hello world program. Since 
you have Gnat you should put that in a file named "hello.adb" and then 
run "gnatmake hello.adb". This should produce an executable file named 
"hello.exe".

I think you should let the Gnat project files wait a bit. Right now you 
can think of them as something GPS uses to store the settings you make. 
Later, when you're more familiar with Ada, you can start learning what 
Gnat project files are useful for.

-- 
Bj�rn Persson                              PGP key A88682FD
                    omb jor ers @sv ge.
                    r o.b n.p son eri nu



^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Setting up an Ada hello world project
  2006-10-31 20:58 ` Björn Persson
@ 2006-10-31 21:05   ` markww
  2006-10-31 21:08     ` markww
  0 siblings, 1 reply; 8+ messages in thread
From: markww @ 2006-10-31 21:05 UTC (permalink / raw)


Ah thanks guys some progress at last. I definitely agree about just
compiling via the command line, my apps will definitely be simple
enough for that. I gave it a shot and this was the output:

C:\Documents and Settings\Mark>gnatmake "C:\helloworld_ada.adb"
gcc -c -IC:\ -I- C:\helloworld_ada.adb
helloworld_ada.adb:4:11: warning: file name does not match unit name,
should be
"hello.adb"
gnatbind -x helloworld_ada.ali
gnatlink helloworld_ada.ali

No .exe is generated under C:\, is that because I received a warning?
Do warnings stop compilation, smae as errors?

Thanks so much,
Mark



On Oct 31, 3:58 pm, Björn Persson <spam-a...@nowhere.nil> wrote:
> markww wrote:
> > I finally got a working compiler for windows. However, I'm not quite
> > sure how to go about compiling a hello world application. The default
> > project created one source file with the text:
> [...]
> > but the compiler complains that there are no Ada sources in this
> > project. How do I go about adding an Ada source? I just want to run
> > something like:
>
> >     with Ada.Text_IO;
>
> >     procedure Hello is
> >     begin
> >        Ada.Text_IO.Put_Line("Hello, world!");
> >     end Hello;You don't need a project file to compile a hello world program. Since
> you have Gnat you should put that in a file named "hello.adb" and then
> run "gnatmake hello.adb". This should produce an executable file named
> "hello.exe".
>
> I think you should let the Gnat project files wait a bit. Right now you
> can think of them as something GPS uses to store the settings you make.
> Later, when you're more familiar with Ada, you can start learning what
> Gnat project files are useful for.
>
> --
> Björn Persson                              PGP key A88682FD
>                     omb jor ers @sv ge.
>                     r o.b n.p son eri nu




^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Setting up an Ada hello world project
  2006-10-31 21:05   ` markww
@ 2006-10-31 21:08     ` markww
  0 siblings, 0 replies; 8+ messages in thread
From: markww @ 2006-10-31 21:08 UTC (permalink / raw)


Oh whoops of course it put the compiled exe where I ran the command
from. I got rid of the warning too. Thanks a lot for your help guys, I
can finally start playing around with it now,

Mark

On Oct 31, 4:05 pm, "markww" <mar...@gmail.com> wrote:
> Ah thanks guys some progress at last. I definitely agree about just
> compiling via the command line, my apps will definitely be simple
> enough for that. I gave it a shot and this was the output:
>
> C:\Documents and Settings\Mark>gnatmake "C:\helloworld_ada.adb"
> gcc -c -IC:\ -I- C:\helloworld_ada.adb
> helloworld_ada.adb:4:11: warning: file name does not match unit name,
> should be
> "hello.adb"
> gnatbind -x helloworld_ada.ali
> gnatlink helloworld_ada.ali
>
> No .exe is generated under C:\, is that because I received a warning?
> Do warnings stop compilation, smae as errors?
>
> Thanks so much,
> Mark
>
> On Oct 31, 3:58 pm, Björn Persson <spam-a...@nowhere.nil> wrote:
>
>
>
> > markww wrote:
> > > I finally got a working compiler for windows. However, I'm not quite
> > > sure how to go about compiling a hello world application. The default
> > > project created one source file with the text:
> > [...]
> > > but the compiler complains that there are no Ada sources in this
> > > project. How do I go about adding an Ada source? I just want to run
> > > something like:
>
> > >     with Ada.Text_IO;
>
> > >     procedure Hello is
> > >     begin
> > >        Ada.Text_IO.Put_Line("Hello, world!");
> > >     end Hello;You don't need a project file to compile a hello world program. Since
> > you have Gnat you should put that in a file named "hello.adb" and then
> > run "gnatmake hello.adb". This should produce an executable file named
> > "hello.exe".
>
> > I think you should let the Gnat project files wait a bit. Right now you
> > can think of them as something GPS uses to store the settings you make.
> > Later, when you're more familiar with Ada, you can start learning what
> > Gnat project files are useful for.
>
> > --
> > Björn Persson                              PGP key A88682FD
> >                     omb jor ers @sv ge.
> >                     r o.b n.p son eri nu- Hide quoted text -- Show quoted text -




^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Setting up an Ada hello world project
  2006-10-31 19:14 Setting up an Ada hello world project markww
  2006-10-31 19:43 ` Jeffrey R. Carter
  2006-10-31 20:58 ` Björn Persson
@ 2006-11-01  7:27 ` Martin Krischik
  2 siblings, 0 replies; 8+ messages in thread
From: Martin Krischik @ 2006-11-01  7:27 UTC (permalink / raw)


markww schrieb:

> I finally got a working compiler for windows. However, I'm not quite
> sure how to go about compiling a hello world application.

See:

http://en.wikibooks.org/wiki/Ada_Programming/Basic#.22Hello.2C_world.21.22_programs

> The default
> project created one source file with the text:
> 
>     project Ada_LinkedList is
>       for Object_Dir use "..\..\..\";
>           for Main use ("main");

You need to provide a "procedure Main" in a file called "main.adb". It 
is possible to override the naming convention - but this is an advanced 
topic.

>     end Ada_LinkedList;
> 
> but the compiler complains that there are no Ada sources in this
> project. How do I go about adding an Ada source? I just want to run
> something like:

Other poster told you not to use project files - but you should not take 
our word for it so here a set working project files for "hello world.":

http://svn.sourceforge.net/viewvc/wikibook-ada/trunk/demos/GNAT/hello_world.gpr?view=markup
http://svn.sourceforge.net/viewvc/wikibook-ada/trunk/demos/GNAT/wikibook_ada.gpr?view=markup

As it is usual in larger project he project files are split into to: A 
general part and a specialized part. You can also see that project files 
are quite powerful and quite an advanced topic.

> Where does one #include this in Ada? 

In C talk: Ada uses pre-compiled header files *only* and they are not 
"#include"-ed but "with"-ed.

Try:

http://en.wikibooks.org/wiki/Ada_Programming/Packages#Using_packages

Martin



^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2006-11-01  7:27 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-10-31 19:14 Setting up an Ada hello world project markww
2006-10-31 19:43 ` Jeffrey R. Carter
2006-10-31 19:56   ` markww
2006-10-31 20:50     ` Michael Bode
2006-10-31 20:58 ` Björn Persson
2006-10-31 21:05   ` markww
2006-10-31 21:08     ` markww
2006-11-01  7:27 ` Martin Krischik

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox