php - 在 Mac Mini lion 服务器上从源代码编译 PHP 失败

标签 php c macos unix

这是我在配置后运行 make 后得到的消息。

Undefined symbols for architecture x86_64:
  "_res_9_init", referenced from:
      _zif_dns_check_record in dns.o
      _zif_dns_get_record in dns.o
      _zif_dns_get_mx in dns.o
  "_res_9_search", referenced from:
      _zif_dns_check_record in dns.o
      _zif_dns_get_record in dns.o
      _zif_dns_get_mx in dns.o
  "_res_9_dn_skipname", referenced from:
      _zif_dns_get_record in dns.o
      _zif_dns_get_mx in dns.o
  "_res_9_dn_expand", referenced from:
      _php_parserr in dns.o
      _zif_dns_get_mx in dns.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

我是如何配置的

./configure --prefix=/usr/ --with-apxs2=/usr/sbin/apxs --with-mysql \
--with-pear --with-pdo-pgsql \
--with-pdo-mysql=/usr/local/mysql --with-mysql-sock=/tmp/mysql.sock \
--with-pgsql --with-zlib \
--with-zlib-dir=/usr \
--with-openssl \
--without-iconv \
--enable-exif \
--enable-ftp \
--enable-mbstring \
--enable-mbregex \
--enable-sockets 

请问有人可以帮忙吗?

最佳答案

这个 3 年多的错误(提到了 herehere,为什么他们还没有修复它?)也可以通过执行以下操作(或者可能通过将不正确的库移出路径)来解决,这也可能有效)。

编辑您的 Makefile 并将以下标志添加到 EXTRA_LIBS = 部分(除了已经存在的其他标志之外):

EXTRA_LIBS = -lsResolv

你提到的第二个错误:ext/phar/phar.php] Error 133 是由于MySQL二进制安装程序安装的“lib”目录中的文件之一 没有绝对路径(这已经是一段时间以来的错误了,为什么 Oracle 不修复它??)。如果您查看您提到的错误行上方的几行,您会看到它说:

Generating phar.php
dyld: Library not loaded: libmysqlclient.18.dylib
  Referenced from: /Users/...

通过执行此操作检查该文件(将下面的版本号替换为您的版本号,例如 mysql-5.x.xx)。请注意结果,它不像其他文件引用那样包含完整路径:

# otool -L /usr/local/mysql-5.6.14-osx10.6-x86_64/lib/libmysqlclient.18.dylib

然后像这样修复它:

# sudo install_name_tool -id /usr/local/mysql-5.6.14-osx10.6-x86_64/lib/libmysqlclient.18.dylib /usr/local/mysql-5.6.14-osx10.6-x86_64/lib/libmysqlclient.18.dylib

再次检查以确保:

# otool -L /usr/local/mysql-5.6.14-osx10.6-x86_64/lib/libmysqlclient.18.dylib

现在,你应该可以编译成功了。

关于php - 在 Mac Mini lion 服务器上从源代码编译 PHP 失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11456965/

相关文章:

php - 从子类 php 和 parent 关键字访问 parents 变量?

php - 如何在 javascript 操作上重新加载 php 函数?

PHP7 给出错误 "PHP Startup: Unable to load dynamic library '/usr/lib64/php/modules/mysqli.so'

c - 你如何在 C 中扫描单个字符?

java - csc -version 正在终端中运行,但不是从我的 java 程序 MAC 运行

php - 使用 php 保存 Jquery 可拖动 DIV 的位置

c - 在结构中填充字符指针

c++ - 手册页中 strchrnul 的具体含义

ios - 如何运行导致框架运行时错误的 iOS 应用程序 "code signature invalid"

ios - set-key-partition-list codesign 之后还是提示key access