我找到了解决办法。
我的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;