Reputation: 5329
I am trying to build a static library using gprbuild. The library does not have a main (which is written in C and linked in later stage) and must be self contained as far as I understand the gpr term for this is "stand-alone" which means, it will not be required to link with anything including the runtime during it's run-time.
My gpr looks like this
project Ada_Foo_Lib is
for Source_Dirs use ("src");
for Object_Dir use "obj";
for Library_Dir use "lib";
for Library_Name use "ada_foo_lib";
for Library_Kind use "static";
package Binder is
for Default_Switches("Ada") use ("-n");
for Required_Switches ("Ada") use ("-n");
end Binder;
end Ada_Foo_Lib;
When I run gprbuild, I see in the log that does not include a call to the binder:
gnatmake -Pada_foo_lib.gpr --create-missing-dirs
gcc-4.9 -c -I- -gnatA /home/temp/src/ada_foo_pack.adb
building static library for project ada_foo_lib
ar cr /home/temp/lib/libada_foo_lib.a /home/temp/obj/ada_foo_pack.o
ranlib /home/temp/lib/libada_foo_lib.a
My problem is that resulting libada_foo_lib.a
does not have adainit
and adafinal
exported. I tried to link it and also verified with an objdump
.
I tried all kinds of combinations of switches but nothing made the binder to be called, unless I changed to Library_Kind
to dynamic
and use Library_Standalone
:
Upvotes: 1
Views: 834
Reputation: 25501
If your library didn’t need to be static, but just to be self-contained (i.e. to include the necessary parts of the Ada runtime within itself), you could say
for Library_Kind use "dynamic";
for Library_Interface use ("One_Of_Your_Units");
for Library_Standalone use "encapsulated";
(you have to have a Library_Interface
, but I don’t think it has to include all the units that export C-visible symbols).
Unfortunately, as you noted, this doesn’t work for static libraries.
Upvotes: 2