Mac OS X PHP 5.4.29编译错误"架构x86_64"的未定义符号

时间:2014-06-17 16:58:31

标签: php macos compilation

尝试在Mac OS X 10.8.4上编译PHP 5.4.29

./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-png-dir=/usr/X11

然后执行 make 并收到此错误:

Undefined symbols for architecture x86_64:
  "_ap_get_server_version", referenced from:
      _zif_apache_get_version in php_functions.o
      _zm_info_apache in php_functions.o
  "_ap_log_error", referenced from:
      _php_handler in sapi_apache2.o
      _php_apache_sapi_log_message in sapi_apache2.o
  "_ap_log_rerror", referenced from:
      _php_handler in sapi_apache2.o
      _php_apache_sapi_log_message in sapi_apache2.o
  "_unixd_config", referenced from:
      _zm_info_apache in php_functions.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [libs/libphp5.bundle] Error 1

之前有人见过吗?任何想法如何解决它?

1 个答案:

答案 0 :(得分:2)

为了记录,我得到了它的工作。我无处可去,所以我决定先升级到 Mavericks (10.9.3)。我在尝试编译PHP时仍然遇到错误,尽管它们与我在Mountain Lion下遇到的原始错误不同。

首先,我需要确保在操作系统升级后安装了命令行工具。出于某种原因,我的Xcode 5.1.1不再在“首选项”中给我这个选项,所以我(重新)在shell中安装了命令行工具:

xcode-select --install 

我设置了一些环境变量来编译Apache和PHP:

MACOSX_DEPLOYMENT_TARGET=10.9
CFLAGS="-arch x86_64 -g -Os -pipe -no-cpp-precomp"
CCFLAGS="-arch x86_64 -g -Os -pipe"
CXXFLAGS="-arch x86_64 -g -Os -pipe"
LDFLAGS="-arch x86_64 -bind_at_load"
export CFLAGS CXXFLAGS LDFLAGS CCFLAGS MACOSX_DEPLOYMENT_TARGET

然后我编译并安装了apr.apache.org上提供的 apr apr-util 。然后编译并安装Apache 2.4.9:

./configure --prefix=/usr --enable-layout=Darwin --enable-cgi --enable-ssl --enable-so --enable-rewrite --enable-mime-magic --enable-suexec --enable-modules=all --enable-mods-shared=all --with-apr=/usr/local/apr --with-apr-util=/usr/local/apr 
make
make install

然后PHP 5.5.13:

./configure  --prefix=/usr  --mandir=/usr/share/man  --infodir=/usr/share/info  --sysconfdir=/private/etc  --with-apxs2=/usr/bin/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-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-freetype-dir=/usr/X11  --with-png-dir=/usr/X11 --with-jpeg-dir=/usr
make
make install

然后恢复了我的旧php.ini和httpd.conf文件,重新启动了apache,它对我有用。这些是主要步骤,但是我需要安装的方式有些小,因为我丢失了库/文件错误。例如,在我编译PHP之前,我需要编译并安装Libjpeg。我使用从http://www.ijg.org/files/下载的 jpegsrc.v9a.tar.gz

我不知道上述步骤对Mountain Lion是否同样有效。