Antoher question in my learning re: gnatmake: *** link failed

Greetings

Follwing the destructions typed in a program called firstprogram.

with Ada.Text_IO;
procedure firstprogram is
– my first Ada program
begin
Ada.Text_IO.Put_Line( “This is my first Ada program.” );
end firstprogram;

which when I try to compile it (using gnat 12.2.0) gives the following results:

$ gnatmake firstprogram
x86_64-linux-gnu-gnatbind-12 -x firstprogram.ali
x86_64-linux-gnu-gnatlink-12 firstprogram.ali
x86_64-linux-gnu-gnatlink-12: executable name “firstprogram” matches source file name “firstprogram”
gnatmake: *** link failed.

which isn’t quite what I expected.

$ ls tells me that I have

b~firstprogram.adb

not the “firstprogram.adb:” I was expecting - - - is there a switch I need to use
with gnatmake so that I get the result I was expecting?

TIA

It sounds like your source file is named “firstprogram”, not “firstprogram.adb”.

Part of gnatmake’s job is to ‘bind’ your program (makes sure that all the units that are needed by your program are compiled and linked in an appropriate order). To do this it generates a procedure which does that and then calls your program. This is generated in files called b~yourprogram.ads, b~yourprogram.adb.

1 Like

That was understood after the first program that I used.

Thanks for the idea(s).

I can see those ‘files’ when I look into the folder.
What I don’t understand is how to change the program so that the program actually compiles. The b~yourprogram.ads is NOT compiled - - - when I try to read it it is absolutely loaded with all kinds of other information but the job isn’t done.

Please what do I do so that the program compiles?

TIA

You need to rename your source code file from just firstprogram to firstprogram.adb .

You should see this (there may be slight differences, depending on your operating system):

$ gnatmake firstprogram.adb
gcc -c firstprogram.adb
gnatbind -x firstprogram.ali
gnatlink firstprogram.ali

So - - - wrote out another called it secondprogram.adb .

(It seemed to work better when there was a space in line 5 between . . . Put_Line and the opening ( .)

Did the

$ gnatmake firstprogram.adb
gcc -c firstprogram.adb
gnatbind -x firstprogram.ali
gnatlink firstprogram.ali

followed by ./secondprogram with a
resultant of

This is my second Ada program.

Operation a success (patient died - - - lol).

Thank you

If I understand you correctly, you’re using gnat, and that’s just a style warning.

If that’s correct, you can ignore the compile-time warning and it will run fine. If you don’t like the style and also don’t like to sift through style warnings while looking for errors, there are ways to disable the warning. Unfortunately, the only one I find dedicated to space before a left parens is -gnatyt, so if you like those, you’re sort of stuck with that, too. But maybe I missed another one.