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

undefined reference to `main' and strange gnat behaviour



Hello,

starting with Ada by reading English's Craft 95 and Barnes 95 books...

Tried to compile simple 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
$ 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 
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. $ ls -al
total 52
drwxr-xr-x 1 gour gour   134 Ruj 23 13:03 ./
drwxr-xr-x 1 gour gour   118 Ruj 21 17:30 ../
-rw-r--r-- 1 gour gour  8382 Ruj 23 13:03 b~hello.adb
-rw-r--r-- 1 gour gour 13401 Ruj 23 13:03 b~hello.ads
-rw-r--r-- 1 gour gour  7763 Ruj 23 13:03 b~hello.ali
-rw-r--r-- 1 gour gour   657 Ruj 23 13:03 b~hello.o
-rw-r--r-- 1 gour gour   117 Ruj 23 13:03 hello.adb
-rw-r--r-- 1 gour gour  1487 Ruj 23 13:03 hello.ali
-rw-r--r-- 1 gour gour   657 Ruj 23 13:03 hello.o

What's wrong and what are those b~hello.? generated files?

I'm using Debian Sid and have GNAT-4.9.


Sincerely,
Gour

-- 
What is night for all beings is the time of awakening 
for the self-controlled; and the time of awakening for 
all beings is night for the introspective sage.



Reply to: