小编Mar*_*wes的帖子

在 Ada 中动态链接库会引入额外的依赖项

我在动态和静态链接 Ada 中的库时遇到问题。我准备了一个最低限度的工作示例。这三个文件定义了一个输出“Hello world”的库:

helloworld_lib.gpr :

project Helloworld_Lib is

   for Library_Name use "helloworld_lib";
   for Source_Files use ("helloworld_lib.adb", "helloworld_lib.ads");
   for Library_Kind use "static";
   for Library_Dir use "obj";

end Helloworld_Lib;
Run Code Online (Sandbox Code Playgroud)

helloworld_lib.adb

with Ada.Text_IO;

package body helloworld_lib is

   procedure Hello is
   begin
      Ada.Text_IO.Put_Line("Hello world");
   end Hello;

end helloworld_lib;
Run Code Online (Sandbox Code Playgroud)

helloworld_lib.ads

with Ada.Text_IO;
use Ada.Text_IO;

package helloworld_lib is

   procedure Hello;

end helloworld_lib;
Run Code Online (Sandbox Code Playgroud)

这两个文件定义了一个导入库并运行它的项目:

helloworld_interface.gpr :

with "helloworld_lib.gpr";

project Helloworld_Interface is

   for Create_Missing_Dirs use "True";
   for Main use ("helloworld_interface.adb");
   for Source_Files use ("helloworld_interface.adb");
   for …
Run Code Online (Sandbox Code Playgroud)

dll ada gnat gnat-gps

5
推荐指数
1
解决办法
269
查看次数

标签 统计

ada ×1

dll ×1

gnat ×1

gnat-gps ×1