need -lresolv on MacOSX 10.6

Jim Basney jbasney at ncsa.uiuc.edu
Fri Sep 11 07:03:46 EST 2009


Hi,

When building OpenSSH 5.2p1 on MacOSX 10.6.0, I get the following ld error

gcc -o ssh ssh.o readconf.o clientloop.o sshtty.o sshconnect.o
sshconnect1.o sshconnect2.o mux.o -L. -Lopenbsd-compat/
-fstack-protector-all -lssh -lopenbsd-compat -lcrypto -lz
Undefined symbols:
  "_res_9_query", referenced from:
      _getrrsetbyname in libopenbsd-compat.a(getrrsetbyname.o)
  "_res_9_getshort", referenced from:
      _parse_dns_rrsection in libopenbsd-compat.a(getrrsetbyname.o)
      _parse_dns_rrsection in libopenbsd-compat.a(getrrsetbyname.o)
      _parse_dns_rrsection in libopenbsd-compat.a(getrrsetbyname.o)
      _getrrsetbyname in libopenbsd-compat.a(getrrsetbyname.o)
      _getrrsetbyname in libopenbsd-compat.a(getrrsetbyname.o)
  "_res_9_getlong", referenced from:
      _parse_dns_rrsection in libopenbsd-compat.a(getrrsetbyname.o)
  "_res_9_init", referenced from:
      _getrrsetbyname in libopenbsd-compat.a(getrrsetbyname.o)
  "_res_9_dn_expand", referenced from:
      _parse_dns_rrsection in libopenbsd-compat.a(getrrsetbyname.o)
      _getrrsetbyname in libopenbsd-compat.a(getrrsetbyname.o)
ld: symbol(s) not found
collect2: ld returned 1 exit status
make: *** [ssh] Error 1

Adding -lresolv to the link line fixes it.

Checking <http://opensource.apple.com/release/mac-os-x-106/>, I see that
Apple's OpenSSH package adds -lresolv to "Extra_LD_Flags".

I notice that /usr/include/resolve.h on MacOSX 10.6.0 no longer contains

  #ifdef BIND_8_COMPAT
  #include <resolv8_compat.h>

as seen in previous MacOSX releases, so we get

  #define res_query res_9_query

which creates the dependency on -lresolv.

OpenSSH's configure script tests for res_query with
AC_TRY_LINK_FUNC(res_query, ...) which doesn't #include <resolv.h>, so
it doesn't detect that -lresolv is needed for res_9_query. The attached
patch is my attempt to fix it.

-Jim
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: openssh-5.2p1.resolv.patch
URL: <http://lists.mindrot.org/pipermail/openssh-unix-dev/attachments/20090910/23c3cc1c/attachment.ksh>


More information about the openssh-unix-dev mailing list