【问题标题】:Compiling PHP from source fails on Mac Mini lion server在 Mac Mini lion 服务器上从源代码编译 PHP 失败
【发布时间】:2012-07-12 12:08:49
【问题描述】:

这是我在配置后运行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 

请问有人可以帮忙吗?

【问题讨论】:

  • 您要编译的 PHP 版本是什么?

标签: php c macos unix


【解决方案1】:

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

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

EXTRA_LIBS = -lsResolv

您提到的第二个错误:ext/phar/phar.php] Error 133 是由于 MySQL 二进制安装程序安装的“lib”目录中的文件之一没有绝对路径 (这个bug已经有一段时间了,为什么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

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

【讨论】:

    【解决方案2】:

    使用本地 mysql 和 mysqli 驱动程序编译 PHP。此错误是由 php 和 mysql 库之间的冲突引起的。如果您不想使用本机驱动程序,请使用“export EXTRA_CFLAGS=-lresolv”,运行 make 将解决未定义的符号。

    将您的配置更改为:

    ./configure \
    --prefix=/usr/ \
    --with-apxs2=/usr/sbin/apxs 
    --with-mysql=mysqlnd \
    --with-mysqli=mysqlnd \
    --with-pdo-mysql=mysqlnd \
    --with-pear --with-pdo-pgsql \
    --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 
    

    顺便说一句,如果你把mysql套接字留在/tmp,别忘了做一个“chmod +t /tmp”

    【讨论】:

    • 好的,没用。不配置过去的 apxs 会给出 /Users/Asgard/php-5.4.4/ext/phar/build_precommand.php > ext/phar/phar.php make: *** [ext/phar/phar.php] 错误 133 消息
    【解决方案3】:

    问题的实际根源仍然模糊,但可以肯定的是我的配置错误。造成问题的冲突只有在从 /usr/bin 删除所有原生 php 的痕迹后才得以解决 - 从 /usr/bin 逐字删除,然后我下载了最新的稳定 php 5.4 tarball 解压它并使用以下选项重新配置:

    ./configure  \
    --prefix=/usr  \
    --mandir=/usr/share/man  \
    --infodir=/usr/share/info  \
    --sysconfdir=/private/etc  \
    --with-apxs2=/usr/sbin/apxs  \
    --enable-cli  \
    --with-config-file-path=/etc  \
    --with-libxml-dir=/usr  \
    --with-openssl=/usr  \
    --with-kerberos=/usr  \
    --with-zlib=/usr  \
    --enable-bcmath  \
    --with-bz2=/usr  \
    --enable-calendar  \
    --with-curl=/usr  \
    --enable-dba  \
    --enable-exif  \
    --enable-ftp  \
    --with-gd  \
    --enable-gd-native-ttf  \
    --with-icu-dir=/usr  \
    --with-iodbc=/usr  \
    --with-ldap=/usr  \
    --with-ldap-sasl=/usr  \
    --with-libedit=/usr  \
    --enable-mbstring  \
    --enable-mbregex  \
    --with-mysql=mysqlnd   \
    --with-mysqli=mysqlnd  \
    --without-pear  \
    --with-pdo-mysql=mysqlnd  \
    --with-mysql-sock=/var/mysql/mysql.sock  \
    --with-readline=/usr  \
    --enable-shmop  \
    --with-snmp=/usr  \
    --enable-soap  \
    --enable-sockets  \
    --enable-sysvmsg  \
    --enable-sysvsem  \
    --enable-sysvshm  \
    --with-tidy  \
    --enable-wddx  \
    --with-xmlrpc  \
    --with-iconv-dir=/usr  \
    --with-xsl=/usr  \
    --enable-zip  \
    --with-pcre-regex  \
    --with-pgsql=/usr  \
    --with-pdo-pgsql=/usr \
    --with-freetype-dir=/usr/X11 \
    --with-jpeg-dir=/usr  \
    --with-png-dir=/usr/X11
    

    在那之后我跑了 $ sudo make test,然后安装。

    然后我重新启动了 apache $ sudo serveradmin 停止/启动网络

    然后它 f*** 起作用了。

    【讨论】:

      猜你喜欢
      • 2011-11-02
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-12-08
      • 1970-01-01
      相关资源
      最近更新 更多