2

I am trying to compile a third part library into my existing application using gnatmake.. And I am getting this error:

gnatmake: "dds.adb" not found
gnatmake: "dds-domainparticipant.adb" not found
gnatmake: "dds-domainparticipantfactory.adb" not found
gnatmake: "dds-publisher.adb" not found
gnatmake: "dds-topic.adb" not found
gnatmake: "dds-publisher_impl.adb" not found
gnatmake: "dds-datawriter_impl.adb" not found
gnatmake: "dds-domainparticipant_impl.adb" not found
gnatmake: "dds-readcondition_impl.adb" not found
gnatmake: "dds-datareader_impl.adb" not found
gnatmake: "dds-subscriber.adb" not found
gnatmake: "dds-condition.adb" not found
gnatmake: "dds-datareader.adb" not found
gnatmake: "dds-statuscondition.adb" not found

I added these to the gnatmake which builds the adp. The -I contains all of the specs (.ads files), and the libnddsadad has all of the o files:

       -I/lib/ndds.4.5d/include/ndds/dds_ada \
       -I/lib/ndds.4.5d/include/ndds/dds_ada/support     \
       -I/lib/ndds.4.5d/include/ndds/dds_ada/support/low-level \

       /lib/Linux/ndds.4.5d/lib/GNATgcc/static/debug/libnddsadad.a \

Why does it want the actual body files? Shouldn’t the specs + .a file be enough? How can I circumvent this?

Cœur
  • 37,241
  • 25
  • 195
  • 267
mainstringargs
  • 13,563
  • 35
  • 109
  • 174

3 Answers3

6

Specs and an archive library are not enough. You need to specify the location of the .ali files. Also, try using the -aI and -aL flags instead of -I.

dalenkruse
  • 240
  • 1
  • 8
  • See also [Source and library search path switches](http://gcc.gnu.org/onlinedocs/gcc-4.5.3/gnat_ugn_unw/Switches-for-gnatmake.html#Switches-for-gnatmake) – trashgod May 03 '11 at 21:02
3

You need to specify:

-largs switches: Linker switches, where switches is a list of switches that are valid switches for gnatlink.

-Ldir: Add directory dir to the list of directories in which the linker will search for libraries.

For example,

-largs -L/lib/Linux/ndds.4.5d/lib/GNATgcc/static/debug -lnddsadad

Addendum: You might also look at

-Adir: Equivalent to -aLdir -aIdir.

trashgod
  • 203,806
  • 29
  • 246
  • 1,045
2

You could create a gnat project file for the library, something like this:

project DDS_Lib is
   for Source_Dirs use ("/usr/include/dds_path");
   for Library_Name use "nddsadad";
   for Library_Dir use "/usr/lib/dds_path";
   for Library_ALI_Dir use "/usr/lib/dds_ali_path";
   for Externally_Built use "true";
end DDS_Lib;

and then in your project file, add with "dds_lib.gpr"; at the beginning. You don't have to add anything to your Linker flags to link with this library, since it is done automagically.

Good Ada libraries already provide such a gpr file, which should get installed in the standard search path (for example /usr/lib/gnat/). If it is installed at a non-standard path, you can add the path to the ADA_PROJECT_PATH environment variable.

Simon Wright
  • 25,108
  • 2
  • 35
  • 62
Rommudoh
  • 1,844
  • 10
  • 11
  • I have a similar issue as OP, but with a custom .a file I made myself, and have your solution building fine -- but when I try to add `with LibraryName;` to my code, the compiler is still looking for an .ads instead of an .a file. I'm trying to do this with a binary .a file where theoretically I don't have the .ali available. Is there a trick to getting this to work that I am missing? – C.D.H. Aug 23 '18 at 21:51