*.ads 文件在使用 makefile 编译 Ada 时未找到
*.ads file not found when compiling Ada with a makefile
我正在尝试编译 ada 程序,但出现以下错误:test.adb:4:06: file "motormachinestate.ads" not found
。当然,问题是 Makefile 有误。我一直在寻找如何修复它,但一直找不到。
程序文件如下:
MotorMachineState.ads:该文件包含包声明。它包含程序使用的过程等-
MotorMachineState.adb:这个文件包含上面的实现。它是一个包体。
test.adb:这是程序的入口点。它使用 MotorMachineState 来执行一些操作。
Makefile:我用来编译的makefile。
下面是对提到的文件的描述:
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;
生成文件
ADA::
gnatmake -c test.adb MotorMachineState.adb
gnatbind test.ali MotorMachineState.ali
gnatlink test.ali MotorMachineState.ali
clean::
rm *.o *.ali main
Ada 中的文件应始终为小写。所以问题的解决方案是将文件 MotorMachineState.ad* 重命名为 motormachinestate.ad*.
此外,gnatbind
和 gnatlink
应该只处理一个 *.ali 文件,因此 Makefile 如下所示:
ADA::
gnatmake -c test.adb motormachinestate.adb
gnatbind test.ali
gnatlink test.ali
clean::
rm *.o *.ali test
编辑
正如@SimonWright 所说,实际上没有必要添加 motormacinestate.adb
到 gnatmake
命令。所以,Makefile 可能是这样的:
ADA::
gnatmake -c test.adb
gnatbind test.ali
gnatlink test.ali
clean::
rm *.o *.ali test
GNAT 要求源文件名全部小写。
要使用 GNAT 构建 Ada 程序(其中所有相关源文件都在当前目录中),您只需 运行:
gnatmake main_source_file.adb
gnatmake
命令知道它需要知道的关于纯 Ada 程序依赖关系的所有信息。
我正在尝试编译 ada 程序,但出现以下错误:test.adb:4:06: file "motormachinestate.ads" not found
。当然,问题是 Makefile 有误。我一直在寻找如何修复它,但一直找不到。
程序文件如下:
MotorMachineState.ads:该文件包含包声明。它包含程序使用的过程等-
MotorMachineState.adb:这个文件包含上面的实现。它是一个包体。
test.adb:这是程序的入口点。它使用 MotorMachineState 来执行一些操作。
Makefile:我用来编译的makefile。
下面是对提到的文件的描述:
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;
生成文件
ADA::
gnatmake -c test.adb MotorMachineState.adb
gnatbind test.ali MotorMachineState.ali
gnatlink test.ali MotorMachineState.ali
clean::
rm *.o *.ali main
Ada 中的文件应始终为小写。所以问题的解决方案是将文件 MotorMachineState.ad* 重命名为 motormachinestate.ad*.
此外,gnatbind
和 gnatlink
应该只处理一个 *.ali 文件,因此 Makefile 如下所示:
ADA::
gnatmake -c test.adb motormachinestate.adb
gnatbind test.ali
gnatlink test.ali
clean::
rm *.o *.ali test
编辑
正如@SimonWright 所说,实际上没有必要添加 motormacinestate.adb
到 gnatmake
命令。所以,Makefile 可能是这样的:
ADA::
gnatmake -c test.adb
gnatbind test.ali
gnatlink test.ali
clean::
rm *.o *.ali test
GNAT 要求源文件名全部小写。
要使用 GNAT 构建 Ada 程序(其中所有相关源文件都在当前目录中),您只需 运行:
gnatmake main_source_file.adb
gnatmake
命令知道它需要知道的关于纯 Ada 程序依赖关系的所有信息。