What is the difference between LDADD and LIBADD?

前端 未结 2 1204
情书的邮戳
情书的邮戳 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:30

    Use the LIBADD primary for libraries, and LDADD for executables. If you were building a libtool library libfoo.la, that depended on another library libbar.la, you would use:

    libfoo_la_LIBADD = libbar.la
    

    If you had other non-libtool libraries, you would also add these with -L and -l options:

    libfoo_la_LIBADD = libbar.la -L/opt/local/lib -lpng
    

    Typically, you would use the configure script to find these extra libraries, and use AC_SUBST to pass them with:

    libfoo_la_LIBADD = libbar.la $(EXTRA_FOO_LIBS)
    

    For a program, just use LDADD :

    myprog_LDADD = libfoo.la # links libfoo, libbar, and libpng to myprog.
    

    Sometimes the boundaries are a bit vague. $(EXTRA_FOO_LIBS) could have been added to myprog_LDADD. Adding dependencies to a libtool (.la) library, and using libtool do all the platform-specific linker magic, is usually the best approach. It keeps all the linker metadata in the one place.

提交回复
热议问题