Next: Finding recommended ISO C and POSIX function substitutes, Previous: Changing your sources for use with Gnulib, Up: Invoking gnulib-tool   [Contents][Index]


3.6 Changing your link commands for use with Gnulib ¶

When you use Gnulib, you need to augment the set of libraries against which your programs and libraries are linked. This is done by augmenting the Automake variable LDADD (for all programs) or prog_LDADD (for a single program prog) or library_la_LIBADD (for a single library library.la).

What do you need to add to this Automake variable?

  1. The reference to the Gnulib library. In the example of section Initial import, this would be lib/libgnu.a for source in the top-level directory, or ../lib/libgnu.a for source in a sibling directory of lib/.
  2. References to additional libraries, brought in by some of the Gnulib modules that you use (directly or indirectly). The complete list of such libraries is printed when you invoke gnulib-tool. Alternatively, you can retrieve the set of additional libraries required by a specific Gnulib module by running
    ./gnulib-tool --extract-recursive-link-directive module
    

    Beware: By looking into the module description file modules/module or by running

    ./gnulib-tool --extract-link-directive module
    

    you would miss the link dependencies of indirectly used modules.