Ada: gnat gprbuild How to link in libraries?
Asked Answered
A

2

6

In this multi-language GPRBuild project I'm working on, I have some c++ library files (*.a) I need to link into my executable. Is there an gpr attribute to tell it what to link in or anyway to pass -l -L switches to the linker?

Assr answered 17/9, 2012 at 17:4 Comment(0)
C
11

Or even better:

Project my_library is
  For externally_built use "true";
  For library_dir use "/where/ever";
  For library_name use "mylibname";
  For source_dirs use (); -- no sources.
  For library_kind use "static";
  -- if it is a static lib .a

  -- for library_kind use "dynamic";
  -- if it is an so.
End my_library;

And in the application project. With "my_library.gpr";

Contemporary answered 11/6, 2014 at 15:32 Comment(1)
Although my answer directly addresses Daniel’s question, yours is indeed a better overall solution to Daniel’s problem; there might, for example, be several application projects.Extemporary
E
11

Within the main project file,

package Linker is
   for Default_Switches ("Ada") use ("-L/where/ever", "-lbar");
end Linker;
Extemporary answered 17/9, 2012 at 23:0 Comment(0)
C
11

Or even better:

Project my_library is
  For externally_built use "true";
  For library_dir use "/where/ever";
  For library_name use "mylibname";
  For source_dirs use (); -- no sources.
  For library_kind use "static";
  -- if it is a static lib .a

  -- for library_kind use "dynamic";
  -- if it is an so.
End my_library;

And in the application project. With "my_library.gpr";

Contemporary answered 11/6, 2014 at 15:32 Comment(1)
Although my answer directly addresses Daniel’s question, yours is indeed a better overall solution to Daniel’s problem; there might, for example, be several application projects.Extemporary

© 2022 - 2024 — McMap. All rights reserved.