What is the difference between LDADD and LIBADD?

前端 未结 2 1222
情书的邮戳
情书的邮戳 2021-01-30 10:50

I\'m trying to setup an automake project that uses a mix of libtool libraries and exectuables, and I\'m having a hard time grokking the automake documentation, esp. as relates t

2条回答
  •  情深已故
    2021-01-30 11:39

    As mentioned in one of the books, LDADD is ADDitional linker(LD) items - i.e. items that are added when performing linking. This would be, for example, when producing programs. LDADD can specify:

    • libtool files e.g. lib/libfudge.la
    • libraries e.g. -lm, or
    • full paths to libraries e.g. /lib/libmagicalwonderland.a
    • link flags & libraries e.g. -L/opt/lib -lmagical

    They are in order of preference - Using the last two is just asking for trouble as they're pointing at things that may or may not be present.

    LIBADD is to specify ADDitional LIBraries to use. This is used when building a library to specify that additional libraries are needed in order to build or make use of the library. You'll see it specified as something like libfred_la_LIBADD =. It can be used to specify libtool libraries, or system libraries and will place these libraries into the resulting libtool .la for the library so when it comes to linking against the library you get all the appropriate libraries brought along.

    You should only specify libraries to link, so, for example, my library libfred.la depends on some math routines i.e. it depends on libm. When I'm specifying the additional libraries for the library, I state:

    libfred_la_LIBADD = -lm
    

    This dependency is encoded when I build the library, and gets passed on to consumers of the library as well.

    The rule of thumb is:

    • LIBADD for things that are being added to a library
    • LDADD for things that are being added to a program

提交回复
热议问题