[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: undefined reference to `main' and strange gnat behaviour



Gour writes:
> with Ada.Text_IO;
> procedure Hello is
> begin
>     Ada.Text_IO.Put ("Hello world!");
>     Ada.Text_IO.New_Line;
> end Hello;
>
> $ gnatmake hello.adb 
> gcc-4.9 -c hello.adb
> gnatbind -x hello.ali
> gnatlink hello.ali
> $ ls -l
> total 36K
> -rwxr-xr-x 1 gour gour  24K Ruj 23 13:01 hello*
> -rw-r--r-- 1 gour gour  118 Ruj 23 13:01 hello.adb
> -rw-r--r-- 1 gour gour 1,5K Ruj 23 13:01 hello.ali
> -rw-r--r-- 1 gour gour 1,7K Ruj 23 13:01 hello.o
> $ ./hello
> Hello world!
>
> Everything fine, so far.
>
> Now, simple change in hello.adb:
>
> $ cat hello.adb 
> with Ada.Text_IO;
> procedure Hello is
> begin
>     Ada.Text_IO.Put ("Hiya world!");
>     Ada.Text_IO.New_Line;
> end Hello;
>
> $ gnatmake hello.adb 

At this point, gnatmake should call gcc-4.9 -c hello.adb (since
hello.adb has changed on disk) but it doesn't in your case.  For me this
worked and I tried both gnat-4.9 4.9.1-1 and 4.9.1-3.

> gnatbind -x hello.ali
> gnatlink hello.ali
> /usr/lib/gcc/x86_64-linux-gnu/4.9/../../../x86_64-linux-gnu/crt1.o: In function `_start': /build/glibc-irh9iM/glibc-2.19/csu/../sysdeps/x86_64/start.S:118: undefined reference to `main' collect2: error: ld returned 1 exit
> status gnatlink: error when calling /usr/bin/gcc-4.9
> gnatmake: *** link failed.

I suggest you "rm -f b~* *.o .ali" and call gnatmake again.  I presume
there was an error wherein some file was modified in an editor but not
on disk?

Anyway, I can only say: "works for me"...

-- 
Ludovic Brenta.


Reply to: