[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

how to add an indirect library linker dependency



Hello.

As far as I know, the current practice for a package providing a
library depending on another library is to mention the linker options
in the *build* project, say for example

  for Library_Options use ("-Wl,--as-needed", "-lgmp", "-lmpfr");

but not to mention them in the *installed* project. I guess that they
are embedded in the dynamic library, as I can compile a program using
that installed project: ld finds the symbols when linking, then when
running. Please look at the attached files for concrete examples.

This scheme is used by many packages with any version of gnat, and
used to work as well for gtkada-2.18/gnat-4.4. Since
gtkada-2.24/gnat-4.6, the package builds fine, but the test fails with
ld complaining about unresolved symbols. The user needs to add "-gnatl
-lgtk and other -l options" to the gnatmake command line.

I am interested in any explanation. Just in case, I tried removing
--as-needed, this does not change anything.

Anyway, Adacore's documentation seems to say that the right solution
is to set
  for Library_Options use (blah);
in the *build* project and
  package Linker is
     for Linker_Options use (blah);
  end Linker;
in the *installed* project. Maybe we should recommend this second
scheme in the policy.
#!/bin/sh
set -C -e -f -u -v
cd ${TMPDIR}

# Use -dbg instead of -dev to avoid mentioning ALIVERSION here
cp /usr/share/doc/libgmpada-dbg/examples/demo.adb .
cp /usr/share/doc/libgmpada-dbg/examples/demo.gpr .
gnatmake -P demo.gpr
./demo
#!/bin/sh
set -C -e -f -u -v
cd ${TMPDIR}

cat > main.adb <<EOF
with Gtk.Main;
with Gnome;
with Gtk.GLArea;

procedure Main is
  B : boolean;
  T : Gtk.Gtk_Type;
begin
   Gtk.Main.Init;
   B := Gnome.Init ("a", "b");
   T := Gtk.GLArea.Get_Type;
end Main;
EOF
cat > p.gpr <<EOF
with "gtkada";
with "gtkglada";
with "gnomeada";

project P is
   for Source_Dirs use (".");
   for Main use ("main.adb");
end P;
EOF
gnatmake -P p.gpr
./main

Reply to: