在 OS X 上从源代码构建 PHP 5.2.10 时链接 libresolv 时出错
首先,我通常会选择使用预编译的 PHP 二进制文件,但需要从源代码构建以满足特定的业务需求。 (我不是那种为了好玩而编译开源应用程序的人。)
我正在 OS X 10.6 上构建,当我尝试 make
PHP 5.2.10 时遇到以下错误Apache 模块 (--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
这些符号是 libresolv
的一部分,包含在 /usr/lib/libresolv.dylib
中> 在 OS X 上(并且至少从 10.4 开始)。 请注意,*.dylib
文件在 Mac 上相当于 Linux 上的 *.so
文件,并且我已经在 libiconv.dylib
中成功编译了通过将 --with-iconv=shared,/usr
传递给 ./configure
,消除了 iconv
库的类似链接器错误。
当我运行 ./configure
时,它会检测到 /usr/include/resolv.h
并在 makefile 中启用它。 但是,我似乎无法弄清楚如何让共享库正确链接。 有什么建议让它发挥作用吗? 我从来没有做过像将自定义链接器标志传递给 ./configure
这样的事情,不幸的是,Google 并没有为我解决这个问题提供任何帮助。
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
尝试将 -lresolv 添加到您的 Makefile 中。
希望这可以帮助。 我从这个讨论中得到了建议。
Try adding -lresolv to your Makefile.
Hope this helps. I got the suggestion from this discussion.
如果在运行配置脚本之前设置配置环境变量,则不必编辑 makefile。 例如:
这个解决方案对我有用。
If you set the configure environment variable before running the configure script, you don't have to edit the makefile. For example:
This solution worked for me.
我建议使用 fink/macports 来解决依赖关系。 使用 macports 构建所有组件,然后从源代码编译 php,将 lib 目录指向 /opt/...
您甚至可以使用 macports 直接从源代码构建 php。
I would recommend resolving the dependencies by using fink/macports. Build all the components using macports and then compile php from source pointing the lib dirs to /opt/...
You can even build php directly from source using macports.
对于那些不知道在哪里添加 -lresolv 的人:)
编辑 Makefile,找到行:
并将 -lresolv 添加到此行,如下所示:
在 MacOS X 10.6 Snow Leopard 上为我工作,同时编译 PHP for LiteSpeed。
For those who can't figure out where to add -lresolv :)
Edit the Makefile, find line:
and add -lresolv to this line like this:
Worked for me on MacOS X 10.6 Snow Leopard while compiling PHP for LiteSpeed.