代码之家  ›  专栏  ›  技术社区  ›  LoneWanderer

Ada库初始化/细化和GPR指令:找不到细化符号

  •  0
  • LoneWanderer  · 技术社区  · 7 年前

    我正在尝试为iOS生成Ada库。 然而,有必要手动执行Ada精化。

    我知道编译器可以生成init符号,稍后可以导入和使用。然而,根据以下探地雷达定义,它不会产生(即: nm <libname>init 具有 <libname> 与GPR指令中定义的值相对应 Library_Name

    project adalib is
        for Languages use ("Ada");
        for Source_Dirs use (project'Project_Dir & "./src");
        for Library_Kind use "static"; --"static" on iOS will produce a .a file
        for Library_Name use project'Name; -- will produce "libadalib.a"
        for Library_Dir use project'Project_Dir & "./lib";
        for Library_Src_Dir use project'Project_Dir & "./includes";
        -- define your favorite compiler, builder, binder, linker options
    end adalib;
    

    我错过了:如何制作这个符号?

    1 回复  |  直到 7 年前
        1
  •  1
  •   LoneWanderer    7 年前

    我找到了解决办法。 我的GPR缺少以下简单指令:

        for Library_Interface use ("mypackage"); -- put whatever packages you want to expose, without .adb/.ads since we're talking about packages
    

    adalibinit 符号via nm 命令 当我在ada代码中导入它时,我也可以使用它,请参见:

    package body mypackage is
        procedure Init_My_Lib
        is
           -- I want to call elaboration;
           pragma import (C, ada_elaboration, "adalibinit");
        begin
           ada_elaboration;
           -- further code
        end Init_My_Lib;
    -- rest of package
    

    因此,完整的探地雷达应为:

    project adalib is
        for Languages use ("Ada");
        for Source_Dirs use (project'Project_Dir & "./src");
        for Library_Kind use "static"; -- will produce a .a file
        for Library_Name use project'Name; -- will produce "libadalib.a"
    
        for Library_Interface use ("mypackage"); -- <=== THIS IS HERE
    
        for Library_Dir use project'Project_Dir & "./lib";
        for Library_Src_Dir use project'Project_Dir & "./includes";
        -- define your favorite compiler, builder, binder, linker options
    end adalib;