comp.lang.ada
 help / color / mirror / Atom feed
* GNAT Project Files?
@ 2005-06-25 16:11 Jacob Sparre Andersen
  2005-06-25 18:14 ` Stephen Leake
  0 siblings, 1 reply; 11+ messages in thread
From: Jacob Sparre Andersen @ 2005-06-25 16:11 UTC (permalink / raw)


I have some difficulties with understanding GNAT project files.  And
since most of tha Ada libraries on Debian seem to use them, it looks
like I have to as well.

First I tried using the GNAT Programming System (2.1.0-4) to generate
a project file, but GPS couldn't generate a file it could understand
itself, so I dropped that idea.

My second solution was to try to put one together myself:
-----
with "/usr/share/ada/adainclude/aws";
with "/usr/share/ada/adainclude/charles";
with "/home/sparre/Ada/Pakker/Strenge/string_arrays";
with "/home/sparre/Ada/Programmer/CGI/Ordlisten/get_random_words";

project Test_Word_Buffer is
   for Object_Dir use ".";
   for Exec_Dir use ".";
   for Main use ("test_word_buffer");
end Test_Word_Buffer;
-----
At least GNAT doesn't complain about syntax errors in this file, but
once it comes to the linking stage I get a whole bunch of errors
looking like these:
-----
b~test_word_buffer.o(.text+0xa32): In function `adainit':
: undefined reference to `aws__os_lib_E'
b~test_word_buffer.o(.text+0xa48): In function `adainit':
: undefined reference to `aws__os_lib___elabs'
b~test_word_buffer.o(.text+0xa4e): In function `adainit':
: undefined reference to `aws__os_lib_E'
-----
What is wrong/missing in the GNAT project file?

Jacob
-- 
Adlai Stevenson said it all when, at an event during the
1956 Presidential campaign, a woman shouted, "You have the
vote of every thinking person!" Stevenson shouted back,
"That's not enough, madam, we need a majority!"




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

* Re: GNAT Project Files?
  2005-06-25 16:11 GNAT Project Files? Jacob Sparre Andersen
@ 2005-06-25 18:14 ` Stephen Leake
  2005-06-25 18:53   ` Jacob Sparre Andersen
  0 siblings, 1 reply; 11+ messages in thread
From: Stephen Leake @ 2005-06-25 18:14 UTC (permalink / raw)
  To: Jacob Sparre Andersen; +Cc: comp.lang.ada

Jacob Sparre Andersen <sparre@nbi.dk> writes:

> I have some difficulties with understanding GNAT project files.  And
> since most of tha Ada libraries on Debian seem to use them, it looks
> like I have to as well.

You need to read both the GNAT user's guide, and the GNAT reference
manual, to get all the relevant information on project files.

> My second solution was to try to put one together myself:
> -----
> with "/usr/share/ada/adainclude/aws";
> with "/usr/share/ada/adainclude/charles";
> with "/home/sparre/Ada/Pakker/Strenge/string_arrays";
> with "/home/sparre/Ada/Programmer/CGI/Ordlisten/get_random_words";

It's better to specify the search path in the ADA_PROJECT_PATH
environment variable, so you can move things around.

> project Test_Word_Buffer is
>    for Object_Dir use ".";
>    for Exec_Dir use ".";
>    for Main use ("test_word_buffer");
> end Test_Word_Buffer;
> -----
> At least GNAT doesn't complain about syntax errors in this file, but
> once it comes to the linking stage I get a whole bunch of errors
> looking like these:
> -----
> b~test_word_buffer.o(.text+0xa32): In function `adainit':
> : undefined reference to `aws__os_lib_E'
> b~test_word_buffer.o(.text+0xa48): In function `adainit':
> : undefined reference to `aws__os_lib___elabs'
> b~test_word_buffer.o(.text+0xa4e): In function `adainit':
> : undefined reference to `aws__os_lib_E'
> -----
> What is wrong/missing in the GNAT project file?

There is apparently a non-Ada library that you need to link with. use:

  package Linker is
     for Switches ("bus_master.adb") use ("-lgds_1553_c");
  end Linker;

-- 
-- Stephe




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

* Re: GNAT Project Files?
  2005-06-25 18:14 ` Stephen Leake
@ 2005-06-25 18:53   ` Jacob Sparre Andersen
  2005-06-25 20:53     ` Pascal Obry
  0 siblings, 1 reply; 11+ messages in thread
From: Jacob Sparre Andersen @ 2005-06-25 18:53 UTC (permalink / raw)


Stephen Leake wrote:
> Jacob Sparre Andersen <sparre@nbi.dk> writes:

> You need to read both the GNAT user's guide, and the GNAT reference
> manual, to get all the relevant information on project files.

I tried that, but apparently I wasn't patient enough with the text.

> > My second solution was to try to put one together myself:
> > -----
> > with "/usr/share/ada/adainclude/aws";
> > with "/usr/share/ada/adainclude/charles";
> > with "/home/sparre/Ada/Pakker/Strenge/string_arrays";
> > with "/home/sparre/Ada/Programmer/CGI/Ordlisten/get_random_words";
> 
> It's better to specify the search path in the ADA_PROJECT_PATH
> environment variable, so you can move things around.

OK.

> > project Test_Word_Buffer is
> >    for Object_Dir use ".";
> >    for Exec_Dir use ".";
> >    for Main use ("test_word_buffer");
> > end Test_Word_Buffer;
[...]
> > What is wrong/missing in the GNAT project file?
> 
> There is apparently a non-Ada library that you need to link with. use:
> 
>   package Linker is
>      for Switches ("bus_master.adb") use ("-lgds_1553_c");
>   end Linker;

More precisely:

   package Linker is
      for Switches ("test_word_buffer.adb") use ("-laws", "-lcharles");
   end Linker;

Thanks.

Jacob
-- 
"War does not determine who is right - only who is left."
                                         -- Bertrand Russell



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

* Re: GNAT Project Files?
  2005-06-25 18:53   ` Jacob Sparre Andersen
@ 2005-06-25 20:53     ` Pascal Obry
  2005-06-26  0:08       ` Stephen Leake
  2005-06-26  0:22       ` Jacob Sparre Andersen
  0 siblings, 2 replies; 11+ messages in thread
From: Pascal Obry @ 2005-06-25 20:53 UTC (permalink / raw)



Jacob Sparre Andersen <sparre@nbi.dk> writes:

> More precisely:
> 
>    package Linker is
>       for Switches ("test_word_buffer.adb") use ("-laws", "-lcharles");
>    end Linker;
> 
> Thanks.

This is not right. If the above works it means that the AWS project file is
wrong. How aws.gpr was built ? Which AWS version are you using ? The whole
point of the Project File is to deal with those issues for you.

Pascal.

-- 

--|------------------------------------------------------
--| Pascal Obry                           Team-Ada Member
--| 45, rue Gabriel Peri - 78114 Magny Les Hameaux FRANCE
--|------------------------------------------------------
--|              http://www.obry.net
--| "The best way to travel is by means of imagination"
--|
--| gpg --keyserver wwwkeys.pgp.net --recv-key C1082595



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

* Re: GNAT Project Files?
  2005-06-25 20:53     ` Pascal Obry
@ 2005-06-26  0:08       ` Stephen Leake
  2005-06-26  7:55         ` Pascal Obry
  2005-06-26  0:22       ` Jacob Sparre Andersen
  1 sibling, 1 reply; 11+ messages in thread
From: Stephen Leake @ 2005-06-26  0:08 UTC (permalink / raw)
  To: Pascal Obry; +Cc: comp.lang.ada

Pascal Obry <pascal@obry.net> writes:

> Jacob Sparre Andersen <sparre@nbi.dk> writes:
>
>> More precisely:
>> 
>>    package Linker is
>>       for Switches ("test_word_buffer.adb") use ("-laws", "-lcharles");
>>    end Linker;
>> 
>> Thanks.
>
> This is not right. If the above works it means that the AWS project file is
> wrong. 

I don't think so. Clearly aws.gpr does not know about
test_word_buffer.adb.

I don't think there is a project file syntax for "use this library
for all executables". Perhaps there should be.

One solution is to use 'pragma Linker ("-laws")' in the Ada source for aws.

Hmm. Maybe you could do (in aws.gpr):

package Linker is
    for Default_Switches ("Ada") use ("-laws");
end Linker;

Then in a user project file you can do:

package Linker
    for Switches ("test_word_buffer.adb") use
       Aws.Linker.Default_Switches;
end Linker;

Better, but still not automatic.

'gprmake' (in GNAT 5.03a) can build both C and Ada code, and link them
together. But that's not quite what you want here, I think.

> How aws.gpr was built ? Which AWS version are you using ? The whole
> point of the Project File is to deal with those issues for you.

Maybe I've missed something; how do you expect the project file to
work here?

-- 
-- Stephe




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

* Re: GNAT Project Files?
  2005-06-25 20:53     ` Pascal Obry
  2005-06-26  0:08       ` Stephen Leake
@ 2005-06-26  0:22       ` Jacob Sparre Andersen
  2005-06-26  7:59         ` Pascal Obry
  1 sibling, 1 reply; 11+ messages in thread
From: Jacob Sparre Andersen @ 2005-06-26  0:22 UTC (permalink / raw)


Pascal Obry <pascal@obry.net> writes:
> Jacob Sparre Andersen <sparre@nbi.dk> writes:

> > More precisely:
> > 
> >    package Linker is
> >       for Switches ("test_word_buffer.adb") use ("-laws", "-lcharles");
> >    end Linker;
> > 
> > Thanks.
> 
> This is not right. If the above works it means that the AWS project
> file is wrong. How aws.gpr was built?

No idea.  It is a part of the Debian package with AWS.  Here's the
non-comment part of it:

-----
with "/usr/share/ada/adainclude/xmlada.gpr";
project AWS is
   for Source_Dirs use ("/usr/share/ada/adainclude/aws");
   for Object_Dir use "/usr/lib/ada/adalib/aws";
   Ada_Switches := "-laws";
   package Linker is
      for Default_Switches ("Ada") use (Ada_Switches);
   end Linker;
end AWS;
-----

> Which AWS version are you using?

2.0p-4 in Debian.

> The whole point of the Project File is to deal with those issues for
> you.

I thought so too before I starte trying to use them, but it is my
experience that they create more problems than they solve.

Jacob
-- 
"Genes don't matter. It's all physics."



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

* Re: GNAT Project Files?
  2005-06-26  0:08       ` Stephen Leake
@ 2005-06-26  7:55         ` Pascal Obry
  2005-06-26 13:00           ` Stephen Leake
  0 siblings, 1 reply; 11+ messages in thread
From: Pascal Obry @ 2005-06-26  7:55 UTC (permalink / raw)



Stephen Leake <stephen_leake@acm.org> writes:

> I don't think so. Clearly aws.gpr does not know about
> test_word_buffer.adb.

That's not correct. I still don't know which AWS version is used but recent
version are built using a "Library Project" and in this case there is no need
to provide the library in the linker options. This is done automatically.

> Maybe I've missed something; how do you expect the project file to
> work here?

Using a *Library* Project File :)

Pascal.

-- 

--|------------------------------------------------------
--| Pascal Obry                           Team-Ada Member
--| 45, rue Gabriel Peri - 78114 Magny Les Hameaux FRANCE
--|------------------------------------------------------
--|              http://www.obry.net
--| "The best way to travel is by means of imagination"
--|
--| gpg --keyserver wwwkeys.pgp.net --recv-key C1082595



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

* Re: GNAT Project Files?
  2005-06-26  0:22       ` Jacob Sparre Andersen
@ 2005-06-26  7:59         ` Pascal Obry
  2005-06-26 13:24           ` Ludovic Brenta
  0 siblings, 1 reply; 11+ messages in thread
From: Pascal Obry @ 2005-06-26  7:59 UTC (permalink / raw)



Jacob Sparre Andersen <sparre@nbi.dk> writes:

> -----
> with "/usr/share/ada/adainclude/xmlada.gpr";
> project AWS is
>    for Source_Dirs use ("/usr/share/ada/adainclude/aws");
>    for Object_Dir use "/usr/lib/ada/adalib/aws";
>    Ada_Switches := "-laws";
>    package Linker is
>       for Default_Switches ("Ada") use (Ada_Switches);
>    end Linker;
> end AWS;
> -----

This project is not a library project and not a project file coming from the
AWS project. So with this project you need to pass the library option to the
linker yourself. Please have a look at the Library Project file and how this
is handled in AWS. AWS has also Library Project to support external libraries
like the one for OpenSSL. Which such an achitecture you just need to add into
your own project file:

   with "aws";

And that's all. If you want SSL support you can use :

   with "aws_ssl";

Pascal.

-- 

--|------------------------------------------------------
--| Pascal Obry                           Team-Ada Member
--| 45, rue Gabriel Peri - 78114 Magny Les Hameaux FRANCE
--|------------------------------------------------------
--|              http://www.obry.net
--| "The best way to travel is by means of imagination"
--|
--| gpg --keyserver wwwkeys.pgp.net --recv-key C1082595



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

* Re: GNAT Project Files?
  2005-06-26  7:55         ` Pascal Obry
@ 2005-06-26 13:00           ` Stephen Leake
  0 siblings, 0 replies; 11+ messages in thread
From: Stephen Leake @ 2005-06-26 13:00 UTC (permalink / raw)
  To: Pascal Obry; +Cc: comp.lang.ada

Pascal Obry <pascal@obry.net> writes:

> Stephen Leake <stephen_leake@acm.org> writes:
>
>> I don't think so. Clearly aws.gpr does not know about
>> test_word_buffer.adb.
>
> That's not correct. I still don't know which AWS version is used but recent
> version are built using a "Library Project" and in this case there is no need
> to provide the library in the linker options. This is done automatically.
>
>> Maybe I've missed something; how do you expect the project file to
>> work here?
>
> Using a *Library* Project File :)

Ok, that certainly makes sense. I guess _I_ haven't read the GNAT
project file manuals recently :).

-- 
-- Stephe




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

* Re: GNAT Project Files?
  2005-06-26  7:59         ` Pascal Obry
@ 2005-06-26 13:24           ` Ludovic Brenta
  2005-06-26 19:40             ` Pascal Obry
  0 siblings, 1 reply; 11+ messages in thread
From: Ludovic Brenta @ 2005-06-26 13:24 UTC (permalink / raw)


Pascal Obry writes:
> Jacob Sparre Andersen writes:
>
>> -----
>> with "/usr/share/ada/adainclude/xmlada.gpr";
>> project AWS is
>>    for Source_Dirs use ("/usr/share/ada/adainclude/aws");
>>    for Object_Dir use "/usr/lib/ada/adalib/aws";
>>    Ada_Switches := "-laws";
>>    package Linker is
>>       for Default_Switches ("Ada") use (Ada_Switches);
>>    end Linker;
>> end AWS;
>> -----
>
> This project is not a library project and not a project file coming
> from the AWS project. So with this project you need to pass the
> library option to the linker yourself. Please have a look at the
> Library Project file and how this is handled in AWS. AWS has also
> Library Project to support external libraries like the one for
> OpenSSL. Which such an achitecture you just need to add into your
> own project file:
>
>    with "aws";
>
> And that's all. If you want SSL support you can use :
>
>    with "aws_ssl";
>
> Pascal.

Pascal, you are correct.  The project file that I supply as part of
libaws (2.0p) is not a library project file.  The reason for this is
that GNAT 3.15p does not support library project files.  Hence, Jacob
needs to specify a linker option in his project file, like so:

with "/usr/share/ada/adainclude/aws";
with "/usr/share/ada/adainclude/charles";
with "/home/sparre/Ada/Pakker/Strenge/string_arrays";
with "/home/sparre/Ada/Programmer/CGI/Ordlisten/get_random_words";

project Test_Word_Buffer is
   for Object_Dir use ".";
   for Exec_Dir use ".";
   for Main use ("test_word_buffer");
   package Linker is
      for Default_Switches ("Ada") use
         (AWS.Ada_Switches, Charles.Ada_Switches,
          -- linker switches from String_Arrays and Get_Random_Words
         );
   end Linker;
end Test_Word_Buffer;

This is explained in the comments in aws.gpr, which Jacob mistakenly
omitted to read, it seems:

        --  Ada Web Server project file for use with GNAT 3.15p
        --  Copyright (c) 2004 Ludovic Brenta <ludovic.brenta@insalien.org>
        --
        --  This program is free software; you can redistribute it and/or modify
        --  it under the terms of the GNU General Public License as published by
        --  the Free Software Foundation; either version 2 of the License, or
        --  (at your option) any later version.
        --
        --  This program is distributed in the hope that it will be useful,
        --  but WITHOUT ANY WARRANTY; without even the implied warranty of
        --  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
        --  GNU General Public License for more details.
        --
        --  This project file is designed to help build applications that use
        --  Ada Web Server.  Here is an example of how to use this project file:
        --
        --  with "/usr/share/ada/adainclude/aws";
        --  project Example is
        --     for Object_Dir use "obj";
        --     for Exec_Dir use ".";
        --     for Main use ("example");
        --     package Linker renames AWS.Linker;
        --     --  Alternatively, if you need additional switches:
        --     --  package Linker is
        --     --     for Default_Switches ("Ada") use (AWS.Ada_Switches & ...)
        --     --  end Linker;
        --  end Example;

        with "/usr/share/ada/adainclude/xmlada.gpr";
        project AWS is
           for Source_Dirs use ("/usr/share/ada/adainclude/aws");
           for Object_Dir use "/usr/lib/ada/adalib/aws";
           Ada_Switches := "-laws";
           package Linker is
              for Default_Switches ("Ada") use (Ada_Switches);
           end Linker;
        end AWS;

This is also explained in the Debian Policy for Ada:

http://www.ada-france.org/debian/debian-ada-policy.html

-- 
Ludovic Brenta.



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

* Re: GNAT Project Files?
  2005-06-26 13:24           ` Ludovic Brenta
@ 2005-06-26 19:40             ` Pascal Obry
  0 siblings, 0 replies; 11+ messages in thread
From: Pascal Obry @ 2005-06-26 19:40 UTC (permalink / raw)



Ludovic,

Good, so this problem fall into the RTFM standard thread :)

The comment you have in the aws.gpr is clear to me and this is the
right solution for GNAT 3.15p.

I think that with GCC 3.4 it should be possible to use a Library
Project file.

Pascal.

-- 

--|------------------------------------------------------
--| Pascal Obry                           Team-Ada Member
--| 45, rue Gabriel Peri - 78114 Magny Les Hameaux FRANCE
--|------------------------------------------------------
--|              http://www.obry.net
--| "The best way to travel is by means of imagination"
--|
--| gpg --keyserver wwwkeys.pgp.net --recv-key C1082595



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

end of thread, other threads:[~2005-06-26 19:40 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-06-25 16:11 GNAT Project Files? Jacob Sparre Andersen
2005-06-25 18:14 ` Stephen Leake
2005-06-25 18:53   ` Jacob Sparre Andersen
2005-06-25 20:53     ` Pascal Obry
2005-06-26  0:08       ` Stephen Leake
2005-06-26  7:55         ` Pascal Obry
2005-06-26 13:00           ` Stephen Leake
2005-06-26  0:22       ` Jacob Sparre Andersen
2005-06-26  7:59         ` Pascal Obry
2005-06-26 13:24           ` Ludovic Brenta
2005-06-26 19:40             ` Pascal Obry

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