NLnetLabs / ldns

LDNS is a DNS library that facilitates DNS tool programming
https://nlnetlabs.nl/ldns
BSD 3-Clause "New" or "Revised" License
295 stars 99 forks source link

Makefile.in: Link with the .la files. #126

Closed orbea closed 3 years ago

orbea commented 3 years ago

When building ldns with slibtool (https://dev.midipix.org/cross/slibtool) it fails.

rdlibtool --mode=link clang -Wunused-function -Wstrict-prototypes -Wwrite-strings -W -Wall -g -O2 linktest.lo -lssl -lcrypto -lldns -o linktest

rdlibtool: lconf: {.name="libtool"}.
rdlibtool: fdcwd: {.fdcwd=AT_FDCWD, .realpath="/tmp/ldns"}.
rdlibtool: lconf: fstatat(AT_FDCWD,".",...) = 0 {.st_dev = 34, .st_ino = 38765}.
rdlibtool: lconf: openat(AT_FDCWD,"libtool",O_RDONLY,0) = 3.
rdlibtool: lconf: found "/tmp/ldns/libtool".
rdlibtool: link: clang .libs/linktest.o -Wunused-function -Wstrict-prototypes -Wwrite-strings -W -Wall -g -O2 -lssl -lcrypto -lldns -o .libs/linktest
/usr/bin/ld: cannot find -lldns
clang-11: error: linker command failed with exit code 1 (use -v to see invocation)
rdlibtool: exec error upon slbt_exec_link_create_executable(), line 1614: (see child process error messages).
rdlibtool: < returned to > slbt_exec_link(), line 1934.
make: *** [Makefile:231: linktest] Error 2

This is because the build links the interneal dependency libldns with -lldns when it should be linking with the libldns.la libtool archive as the libtool documentation suggests. This ensures that both slibtool and GNU libtool which is far more permissive compiles. This PR fixes at least the cases in the Makefile.in file.

Also see this downstream issue: https://bugs.gentoo.org/778794

orbea commented 3 years ago

This is also described in the automake documentation.

We recommend that you avoid using -l options in LDADD or prog_LDADD when referring to libraries built by your package. Instead, write the file name of the library explicitly as in the above cpio example. Use -l only to list third-party libraries. If you follow this rule, the default value of prog_DEPENDENCIES will list all your local libraries and omit the other ones.

https://www.gnu.org/software/automake/manual/html_node/Linking.html

wtoorop commented 3 years ago

Of course. This must have been a leftover from some earlier build versions (without libtool)