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

时间:2022-09-01 08:31:47

Trying to compile PHP 5.4.29 on Mac OS X 10.8.4

尝试在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

then doing make and getting this error:

然后做这个错误:

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

Anyone seen this before? Any ideas how to fix it?

有人见过吗?有什么办法解决吗?

1 个解决方案

#1


2  

For the record, I got it working. I was getting nowhere so I've decided to first upgrade to Mavericks (10.9.3). I was still getting errors while trying to compile PHP, although they were different from the original error I was getting under Mountain Lion.

为了记录,我成功了。我什么都没得到,所以我决定先升级到小牛(10.9.3)。我在编译PHP时仍然会出错,尽管它们与我在Mountain Lion下遇到的原始错误不同。

First, I needed to make sure the Command Line Tools were installed after OS upgrade. For some reason my Xcode 5.1.1 doesn't give me this option in "Preferences" anymore, so I (re)installed Command Line Tools in shell:

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

xcode-select --install 

I set some environment variables to compile Apache and PHP:

我设置了一些环境变量来编译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

Then I compiled and installed apr and apr-util which are available on apr.apache.org. Then compiled and installed Apache 2.4.9:

然后我编译并安装apr和apr-util,这些在apache.org上可用。然后编译并安装了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

Then PHP 5.5.13:

然后,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

Then restored my old php.ini and httpd.conf files, restarted apache, and it worked for me. These are major steps, but there were smaller things along the way I needed to install because I was getting missing libraries/files errors. For example, before I could compile PHP, I needed to compile and install Libjpeg. I used jpegsrc.v9a.tar.gz downloaded from http://www.ijg.org/files/.

然后恢复我的旧php。ini和httpd。conf文件,重新启动apache,它为我工作。这些是主要的步骤,但是在我安装的过程中有一些更小的事情,因为我正在丢失库/文件错误。例如,在我编译PHP之前,我需要编译和安装Libjpeg。我用jpegsrc.v9a.tar。广州从http://www.ijg.org/files/下载。

I don't know if above steps would work equally well for Mountain Lion.

我不知道上述步骤是否对美洲狮同样有效。

#1


2  

For the record, I got it working. I was getting nowhere so I've decided to first upgrade to Mavericks (10.9.3). I was still getting errors while trying to compile PHP, although they were different from the original error I was getting under Mountain Lion.

为了记录,我成功了。我什么都没得到,所以我决定先升级到小牛(10.9.3)。我在编译PHP时仍然会出错,尽管它们与我在Mountain Lion下遇到的原始错误不同。

First, I needed to make sure the Command Line Tools were installed after OS upgrade. For some reason my Xcode 5.1.1 doesn't give me this option in "Preferences" anymore, so I (re)installed Command Line Tools in shell:

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

xcode-select --install 

I set some environment variables to compile Apache and PHP:

我设置了一些环境变量来编译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

Then I compiled and installed apr and apr-util which are available on apr.apache.org. Then compiled and installed Apache 2.4.9:

然后我编译并安装apr和apr-util,这些在apache.org上可用。然后编译并安装了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

Then PHP 5.5.13:

然后,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

Then restored my old php.ini and httpd.conf files, restarted apache, and it worked for me. These are major steps, but there were smaller things along the way I needed to install because I was getting missing libraries/files errors. For example, before I could compile PHP, I needed to compile and install Libjpeg. I used jpegsrc.v9a.tar.gz downloaded from http://www.ijg.org/files/.

然后恢复我的旧php。ini和httpd。conf文件,重新启动apache,它为我工作。这些是主要的步骤,但是在我安装的过程中有一些更小的事情,因为我正在丢失库/文件错误。例如,在我编译PHP之前,我需要编译和安装Libjpeg。我用jpegsrc.v9a.tar。广州从http://www.ijg.org/files/下载。

I don't know if above steps would work equally well for Mountain Lion.

我不知道上述步骤是否对美洲狮同样有效。