comp.lang.ada
 help / color / mirror / Atom feed
* Can't create executable file.
@ 2014-03-06  8:35 oktawian.lagiewski
  2014-03-06  8:41 ` Dmitry A. Kazakov
  2014-03-06 20:45 ` Robert A Duff
  0 siblings, 2 replies; 3+ messages in thread
From: oktawian.lagiewski @ 2014-03-06  8:35 UTC (permalink / raw)


When i use gcc - program.adb i get two new files (ali and o). I wanted to create
executable so i typed gnatbind program but i get message:

"program.adb:1: Program cannot be used as a main program.
Help me please, I'm trying to learn but there is not much info about command prompt compiling. Below is the code for .adb and .ads :

--program.adb

with Ada.Text_IO;
use Ada.Text_IO;

Package body Program is

	procedure program2 is

		begin
		Put_Line ("to jest program!");
	
	end program2;

	function testy(A: in out Integer)return Integer is
		Average: Integer;
		begin
		Average:= 2*A;
		Put_Line("A is equal to: " & Integer'Image(Average));
		return Average;
	end testy;

end program;




-------------------------------------------

--program.ads

package program is

	procedure program2;

	function testy(A: in out integer) return Integer;

end program;

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

* Re: Can't create executable file.
  2014-03-06  8:35 Can't create executable file oktawian.lagiewski
@ 2014-03-06  8:41 ` Dmitry A. Kazakov
  2014-03-06 20:45 ` Robert A Duff
  1 sibling, 0 replies; 3+ messages in thread
From: Dmitry A. Kazakov @ 2014-03-06  8:41 UTC (permalink / raw)


On Thu, 6 Mar 2014 00:35:04 -0800 (PST), oktawian.lagiewski@gmail.com
wrote:

> When i use gcc - program.adb i get two new files (ali and o). I wanted to create
> executable so i typed gnatbind program but i get message:
> 
> "program.adb:1: Program cannot be used as a main program.
> Help me please, I'm trying to learn but there is not much info about
> command prompt compiling. Below is the code for .adb and .ads :

[...]

You put program2 into a package (Program). Such program cannot be used as
main. Move it outside the package, e.g. into the file program2.adb:

procedure Program2 is
begin
   ...
end Program2;

-- 
Regards,
Dmitry A. Kazakov
http://www.dmitry-kazakov.de


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

* Re: Can't create executable file.
  2014-03-06  8:35 Can't create executable file oktawian.lagiewski
  2014-03-06  8:41 ` Dmitry A. Kazakov
@ 2014-03-06 20:45 ` Robert A Duff
  1 sibling, 0 replies; 3+ messages in thread
From: Robert A Duff @ 2014-03-06 20:45 UTC (permalink / raw)


oktawian.lagiewski@gmail.com writes:

> When i use gcc - program.adb i get two new files (ali and o). I wanted to create
> executable so i typed gnatbind program but i get message:

You don't need to use gcc and gnatbind.  You should use gnatmake or
gprbuild instead.

> "program.adb:1: Program cannot be used as a main program.

The "main" must be a library unit procedure with no parameters.
You put most of your code in packages, in files like this_package.ads,
this_package.adb, that_package.ads, that_package.adb.  Then you have
a main procedure (not a package), perhaps program.adb.  This procedure with's
one or more packages and calls things in them.

Then you say:

    gnatmake -gnata -gnato -g -O0 program.adb

and it will invoke gcc and gnatbind automatically.

The switches "-gnata -gnato -g -O0" are good for debugging builds.
You can look up what they mean, if you like.

You can put all your code in program.adb, but that doesn't scale
well.  Sooner or later you're going to want separate library
packages.

- Bob

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

end of thread, other threads:[~2014-03-06 20:45 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-03-06  8:35 Can't create executable file oktawian.lagiewski
2014-03-06  8:41 ` Dmitry A. Kazakov
2014-03-06 20:45 ` Robert A Duff

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