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


c - Compiling PHP from source fails on Mac Mini lion server

这是我在配置后运行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年多历史的错误(这里提到了,为什么他们还没有修复它?)也可以通过执行以下操作来解决(或者可能通过将不正确的库移出路径来解决,这可能也有效)。

编辑您的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

现在,您应该能够成功编译。

使用本地mysql和mysqli驱动程序编译PHP。这个错误是由php和mysql-libs之间的冲突引起的。如果您不想使用本机驱动程序,请使用"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"

问题的实际来源仍然很模糊,但可以肯定的是,我的配置是错误的。创建问题的冲突只有在删除了本地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进行测试,然后安装。

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

然后它f***工作。