I have built a static library in ADA with Gnatstudio/Gprbuild. Now, I would like to use it in a executable project, but I only want to give .ads files and binary .a. No .adb.
My executable project gpr file looks like this:
with "../Libraries/my_lib.gpr";
project Test is
for Source_Dirs use ("src");
for Object_Dir use "obj";
for Main use ("test.adb");
package Linker is
for Default_Switches ("ada") use ("-L../Libraries/lib", "-lmy_lib");
end Linker;
end Test;
and library gpr file looks like this:
library project my_lib is
for Languages use ("Ada");
for Library_Name use "my_lib";
for Source_Dirs use ("src");
for Object_Dir use "obj";
for Library_Dir use "lib";
for Library_Kind use "static";
end my_lib;
When I compile project with library containing ads and adb files in library src dir, everything works fine and compiles like a charm.
But when I remove adb files from library src directory, gpbuild complains it cannot compile ads files.
Compile
[Ada] my_lib.ads
cannot generate code for file my_lib.ads (package spec)
And, yes, it’s right. It cannot compile standalone ads file.
If I add for Excluded_Source_Files use ("my_lib.ads");
in my_lib.gpr, then compiler complains it cannot find my_lib.ads:
Compile
[Ada] test.adb
test.adb:2:06: error: file "my_lib.ads" not found
So, here is my question: How can I give a project a static library with only .ads and .a file BUT prevents compiler to try compiling standalone ads file as they are necessary for dependency but do not need to be compiled.
It so easy to do in C/C++, I’m a bit surprized how hard it is to do in ADA.
Sébastien DI MERCURIO is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.