Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Errors linking libresolv when building PHP 5.2.10 from source on OS X

To begin with, I would normally opt to use a pre-compiled binary of PHP, but am required to build from source for a specific business need. (I'm not the type that compiles open-source apps just for kicks.)

I'm building on OS X 10.6 and am running into the following error when I try to make PHP 5.2.10 as an Apache module (--with-apxs2):

Undefined symbols:
  "_res_9_dn_expand", referenced from:
      _zif_dns_get_mx in dns.o
  "_res_9_search", referenced from:
      _zif_dns_get_mx in dns.o
      _zif_dns_check_record in dns.o
  "_res_9_dn_skipname", referenced from:
      _zif_dns_get_mx in dns.o
      _zif_dns_get_mx in dns.o
ld: symbol(s) not found

These symbols are part of libresolv, which is included at /usr/lib/libresolv.dylib on OS X (and has been since at least 10.4). Note that *.dylib files are the Mac equivalent of *.so files on Linux, and I've successfully compiled in libiconv.dylib already by passing --with-iconv=shared,/usr to ./configure, which eliminated similar linker errors for the iconv library.

When I run ./configure, it detects /usr/include/resolv.h and enables it in the makefile. However, I can't seem to figure out how to get the shared library to link in correctly. Any tips on getting that to work? I've never done anything like passing custom linker flags to ./configure, and Google has been no help to me for this problem, unfortunately.


Edit: I'm building from this TAR download if anyone wants to try to replicate the error on Snow Leopard.

like image 392
Quinn Taylor Avatar asked Jul 30 '09 04:07

Quinn Taylor


2 Answers

Try adding -lresolv to your Makefile.

Hope this helps. I got the suggestion from this discussion.

like image 119
Sean A.O. Harney Avatar answered Sep 30 '22 06:09

Sean A.O. Harney


If you set the configure environment variable before running the configure script, you don't have to edit the makefile. For example:

LIBS=-lresolv ./configure --with-apxs2 --with-gd (etc.)

This solution worked for me.

like image 26
chronon Avatar answered Sep 30 '22 05:09

chronon