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

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



On Tue, 23 Sep 2014 19:07:54 +0200
Ludovic Brenta
<ludovic@ludovic-brenta.org> wrote:

> 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?

Be assured that I tried that in the very beginning, but it didn't work.

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

Now, you may laugh about it, but what can you say about this:

$ cat hello.adb 
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

$ ./hello
Hello world!

$ emacs -nw 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 
gcc-4.9 -c hello.adb
gnatbind -x hello.ali
gnatlink hello.ali

$ ./hello
Hiya world!

$ vim hello.adb 

$ cat hello.adb 
with Ada.Text_IO;
procedure Hello is
begin
    Ada.Text_IO.Put ("Hello world!");
    Ada.Text_IO.New_Line;
end Hello;

$ gnatmake hello.adb 
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.


iow., it works when I edit file with Emacs and it fails when it's edited
with Vim. :-)

Seriously, it seems that something mystical is going on in the
background...maybe some interference with GPS/gprbuild/whatever...but I
do not have any clue. :-(

Any hint?


Sincerely,
Gour

-- 
The senses are so strong and impetuous, O Arjuna, 
that they forcibly carry away the mind even of a man 
of discrimination who is endeavoring to control them.



Reply to: