comp.lang.ada
 help / color / mirror / Atom feed
From: hreba <hreba@terra.com.br>
Subject: Undefined reference errors and strange new files appearing
Date: Sat, 21 Jun 2014 19:21:52 -0300
Date: 2014-06-21T19:21:52-03:00	[thread overview]
Message-ID: <c0mes2FnvajU1@mid.individual.net> (raw)

Hi,

Still struggling to get a foot into Ada.

I wrote a simple abstract linear list library,  "gen-lists", and a test 
programs test_genlists which uses it. The files are:

   gen-lists.ads		abstract linear list
   gen-lists.adb
   test_lists_aux.ads	concrete extension of the list
   test_lists_aux.adb
   test_lists.adb	main subprogram

The project file gen.gpr for the library is

---------------------------------------------------------------------
library project Gen is

    for Library_Name use "Gen";

    for Library_Dir use "../All";
    for Source_Dirs use ("src");
    for Object_Dir use "obj";

    package Compiler is
       for Default_Switches ("ada") use ("-gnatf", "-gnato", "-gnat05", 
"-g");
    end Compiler;

end Gen;
---------------------------------------------------------------------

and test_genlists.gpr for the test program:

---------------------------------------------------------------------
with "../../gen.gpr";

project Test_Genlists is

    for Main use ("test_lists.adb");

    package Compiler is
       for Default_Switches ("ada") use ("-g", "-gnatf", "-gnat05");
    end Compiler;

    package Linker is
       for Default_Switches ("ada") use ("-g");
    end Linker;

end Test_Genlists;
---------------------------------------------------------------------

Now "gnatmake -Ptest_genlists" gets me

---------------------------------------------------------------------
gcc-4.6 -c -g -gnatf -gnat05 -I- -gnatA 
/home/frank/Lib/Ada/Gen/tests/Test_gen-lists/test_lists.adb
gcc-4.6 -c -gnatf -gnato -gnat05 -g -I- -gnatA 
/home/frank/Lib/Ada/Gen/src/gen.ads
gcc-4.6 -c -gnatf -gnato -gnat05 -g -I- -gnatA 
/home/frank/Lib/Ada/Gen/src/gen-lists.adb
gcc-4.6 -c -g -gnatf -gnat05 -I- -gnatA 
/home/frank/Lib/Ada/Gen/tests/Test_gen-lists/test_lists_aux.adb

building static library for project gen
ar cr /home/frank/Lib/Ada/All/libGen.a 
/home/frank/Lib/Ada/Gen/obj/gen-lists.o ...
ranlib /home/frank/Lib/Ada/All/libGen.a
gnatbind -I- -x /home/frank/Lib/Ada/Gen/tests/Test_gen-lists/test_lists.ali
gnatlink /home/frank/Lib/Ada/Gen/tests/Test_gen-lists/test_lists.ali -g 
-L/home/frank/Lib/Ada/All/ -lGen -o 
/home/frank/Lib/Ada/Gen/tests/Test_gen-lists/test_lists
b~test_lists.o: In function `adainit':
/home/frank/Lib/Ada/Gen/tests/Test_gen-lists/b~test_lists.adb:158: 
undefined reference to `gen__lists___elabs'
/home/frank/Lib/Ada/Gen/tests/Test_gen-lists/b~test_lists.adb:159: 
undefined reference to `gen__lists_E'
/home/frank/Lib/Ada/Gen/tests/Test_gen-lists/test_lists_aux.o: In 
function `test_lists_aux__itemdIP':
test_lists_aux.adb:(.text+0x2b): undefined reference to 
`gen__lists__itemdIP'
/home/frank/Lib/Ada/Gen/tests/Test_gen-lists/test_lists_aux.o: In 
function `test_lists_aux__itemdSR':
test_lists_aux.adb:(.text+0x65): undefined reference to 
`gen__lists__itemdSR'
/home/frank/Lib/Ada/Gen/tests/Test_gen-lists/test_lists_aux.o: In 
function `test_lists_aux__itemdSW':
test_lists_aux.adb:(.text+0x99): undefined reference to 
`gen__lists__itemdSW'
...
--------------------------------------------------------------------

The 3 dots mean a bunch of further error messages. Besides this, the new 
files

   b~test_lists.adb  b~test_lists.ads  b~test_lists.ali  b~test_lists.o

appear out of nowhere.

I guess I forgot something in the project files. Nevertheless I 
reproduce the start of my sources:

gen-lists.ads:
-------------------------------------------------------------------
-- Abstract linear lists

package Gen.Lists is

    -- the list and its primitive operations

    type ItemD is abstract tagged private;
    type Item is access all ItemD'Class;
    type List is limited private;

    function IsEmpty (l: List) return boolean;
    function Next (i: access ItemD) return Item;
    procedure Append (l: in out List; i: Item);
    ...
-------------------------------------------------------------------

gen-lists.adb:
-------------------------------------------------------------------
--Abstract linear lists

package body Gen.Lists is

    -- primitive list operations

    function IsEmpty (l:List) return Boolean is
    begin return l.first=null;
    end IsEmpty;


    function Next (i:access ItemD) return Item is
    begin return i.next;
    end Next;


    procedure Append (l: in out List; i:Item) is
    begin
       if l.first=null then l.first:= i; else l.last.next:= i; end if;
       l.last:= i;
    end Append;
    ...
--------------------------------------------------------------------

test_lists_aux.ads:
--------------------------------------------------------------------
-- Test of Gen.Lists

with Gen.Lists;

package test_lists_aux is

    type ItemD is new Gen.Lists.ItemD with
       record
          ch:	Character;
       end record;
    type Item is access all ItemD;

    function NewItem (c: Character) return Item;
    ...
-------------------------------------------------------------------

test_lists_aux.adb:
-------------------------------------------------------------------
with Ada.Text_IO;	use Ada.Text_IO;

package body test_lists_aux is

function NewItem (c: Character) return Item is
    i: Item;
begin
    i:= new ItemD;
    i.ch := c;
    return i;
end NewItem;
...
-------------------------------------------------------------------

test_lists.adb:
-------------------------------------------------------------------
-- Test of Gen.Lists

with Ada.Text_IO;  use Ada.Text_IO;
with Gen.Lists;
with test_lists_aux;

procedure Test_Lists is
    a, b, c, d, e:	test_lists_aux.Item;
    list:		Gen.Lists.List;
begin
    -- print header
    Put_Line("");
    Put_Line ("Test of Gen.Lists");
    Put_Line ("-----------------");
    -- create list
    a:= test_lists_aux.NewItem ('a');
    b:= test_lists_aux.NewItem ('b');
    c:= test_lists_aux.NewItem ('c');
    d:= test_lists_aux.NewItem ('d');
    e:= test_lists_aux.NewItem ('e');
    Gen.Lists.Append (list, Gen.Lists.Item(a));
    Gen.Lists.Append (list, Gen.Lists.Item(b));
    ...
-----------------------------------------------------------------

What am I doing wrong?

-- 
Frank Hrebabetzky		+55 / 48 / 3235 1106
Florianopolis, Brazil

             reply	other threads:[~2014-06-21 22:21 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-06-21 22:21 hreba [this message]
2014-06-22  5:56 ` Undefined reference errors and strange new files appearing Dmitry A. Kazakov
2014-06-22  9:04   ` Georg Bauhaus
2014-06-22 16:08     ` hreba
2014-06-22 15:51   ` hreba
2014-06-22 20:06     ` Dmitry A. Kazakov
2014-06-22 20:30       ` hreba
2014-06-22 20:43   ` Simon Wright
2014-06-22 20:50 ` Simon Wright
2014-06-24  1:56   ` hreba
replies disabled

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