1

I am trying to compile an ada program but I am having the following error: test.adb:4:06: file "motormachinestate.ads" not found. Of course, the problem is that the Makefile is wrong. I have been searching how to fix it but I have been unable.

The program files are the following:

  • MotorMachineState.ads: This file contains a package declaration. It contains procedures etc. that are used by the program-

  • MotorMachineState.adb: This file contains the above one's implementation. it is a package body.

  • test.adb: This is the program's entry point. It uses the MotorMachineState to perform some operations.

  • Makefile: The makefile I am using to compile.

Below there is a description of the mentioned files:

MotorMachineState.ads

package MotorMachineState is 
    protected Motor is
         [...]
    end Motor;
end MotorMachineState;

MotorMachineState.adb

with Ada.Text_IO;
with Ada.Real_Time;
with Ada.Integer_Text_IO; 

use Ada.Text_IO;
use Ada.Real_Time;
use Ada.Integer_Text_IO;


package body MotorMachineState is 

    protected body Motor is
        [...]
    end Motor;

end MotorMachineState;

test.adb

with Ada.Text_IO;
with Ada.Real_Time;
with Ada.Integer_Text_IO; 
with MotorMachineState; 

use Ada.Text_IO;
use Ada.Real_Time;
use Ada.Integer_Text_IO;
use MotorMachineState;

procedure test is
begin
    Put_Line("This is a test");
    Motor.setPower(20);
    [...]
end test;

Makefile

ADA::
    gnatmake -c test.adb MotorMachineState.adb
    gnatbind test.ali MotorMachineState.ali
    gnatlink test.ali MotorMachineState.ali 

clean::
    rm *.o *.ali main
trashgod
  • 203,806
  • 29
  • 246
  • 1,045
Dan
  • 2,452
  • 20
  • 45
  • I'm assuming you have a reason to reinvent the dependency wheel using poor old `make`, since the Ada language has built-in support for dependency management of compilation units; the support is also more elaborate than `make`. `gnatmake` (or, more recently `gprbuild`) provide for that when using GNAT. The `gprclean` program might be of interest. The GPR section of the manual installed with the compiler is useful. โ€“ B98 Mar 26 '17 at 19:28

2 Answers2

1

Files in Ada should be always with lower case. So the problem's solution is to rename the files MotorMachineState.ad* to motormachinestate.ad*.

In addition, the gnatbind and gnatlink should handle only one *.ali file, so the Makefile looks like this:

ADA::
    gnatmake -c test.adb motormachinestate.adb
    gnatbind test.ali 
    gnatlink test.ali  

clean::
    rm *.o *.ali test

EDIT

As @SimonWright says, actually there is no need to add the motormacinestate.adb to the gnatmake command. So, the Makefile could be like this:

ADA::
    gnatmake -c test.adb
    gnatbind test.ali 
    gnatlink test.ali  

clean::
    rm *.o *.ali test
Dan
  • 2,452
  • 20
  • 45
  • 1
    This is not required by Ada, which does not define how the [_library_](http://www.ada-auth.org/standards/12rm/html/RM-10.html) is stored; `GNAT` uses the file system; see also [ยง3.3.1 File Naming Rules](https://gcc.gnu.org/onlinedocs/gnat_ugn/File-Naming-Rules.html). โ€“ trashgod Mar 26 '17 at 17:43
  • 1
    You could get away with just `gnatmake test.adb`, since `gnatmake` knows what to do. Or you could run on a case-insensitive filesystem (Windows, Mac :-) โ€“ Simon Wright Mar 26 '17 at 18:07
1

GNAT expects source file names to be all lower-case.

To build an Ada program (where all relevant source files are in the current directory) with GNAT, you simply run:

gnatmake main_source_file.adb

The gnatmake command knows all it need to know about dependencies of pure-Ada programs.

Jacob Sparre Andersen
  • 6,733
  • 17
  • 22