2

我正在尝试使用 gnatmake 将第三方库编译到我现有的应用程序中。我收到此错误:

gnatmake: "dds.adb" not found
gnatmake: "dds-domainparticipant.adb" not found
gnatmake: "dds-domainparticipantfactory.adb" not found
gnatmake: "dds-publisher.adb" not found
gnatmake: "dds-topic.adb" not found
gnatmake: "dds-publisher_impl.adb" not found
gnatmake: "dds-datawriter_impl.adb" not found
gnatmake: "dds-domainparticipant_impl.adb" not found
gnatmake: "dds-readcondition_impl.adb" not found
gnatmake: "dds-datareader_impl.adb" not found
gnatmake: "dds-subscriber.adb" not found
gnatmake: "dds-condition.adb" not found
gnatmake: "dds-datareader.adb" not found
gnatmake: "dds-statuscondition.adb" not found

我将这些添加到构建 adp 的 gnatmake 中。-I 包含所有规范(.ads 文件),而 libnddsadad 包含所有 o 文件:

       -I/lib/ndds.4.5d/include/ndds/dds_ada \
       -I/lib/ndds.4.5d/include/ndds/dds_ada/support     \
       -I/lib/ndds.4.5d/include/ndds/dds_ada/support/low-level \

       /lib/Linux/ndds.4.5d/lib/GNATgcc/static/debug/libnddsadad.a \

为什么它需要实际的正文文件?specs + .a 文件不应该足够吗?我该如何规避这个?

4

3 回答 3

6

规范和存档库是不够的。您需要指定 .ali 文件的位置。此外,尝试使用 -aI 和 -aL 标志而不是 -I。

于 2011-05-03T20:42:55.317 回答
3

您需要指定:

-largs switches:链接器开关,其中switches是对 . 有效的开关列表gnatlink

-Ldir:将目录添加dir到链接器将在其中搜索库的目录列表中。

例如,

-largs -L/lib/Linux/ndds.4.5d/lib/GNATgcc/static/debug -lnddsadad

附录:你也可以看看

-Adir: 相当于-aLdir -aIdir

于 2011-05-03T20:41:01.810 回答
2

您可以为该库创建一个 gnat 项目文件,如下所示:

project DDS_Lib is
   for Source_Dirs use ("/usr/include/dds_path");
   for Library_Name use "nddsadad";
   for Library_Dir use "/usr/lib/dds_path";
   for Library_ALI_Dir use "/usr/lib/dds_ali_path";
   for Externally_Built use "true";
end DDS_Lib;

然后在您的项目文件中,with "dds_lib.gpr";在开头添加。您无需向链接器标志添加任何内容即可与此库链接,因为它是自动完成的。

好的 Ada 库已经提供了这样一个 gpr 文件,它应该安装在标准搜索路径中(例如 /usr/lib/gnat/)。如果安装在非标准路径,可以将路径添加到ADA_PROJECT_PATH环境变量中。

于 2011-05-05T06:28:12.127 回答