mac 安装PHP7提示“ld: symbol(s) not found for architecture x86_64”

系统版本:mac osx 10.11.2、 Xcode 7.2

➜  php-7.0.0  uname -a
Darwin MacBook-Pro.local 15.2.0 Darwin Kernel Version 15.2.0: Fri Nov 13 19:56:56 PST 2015; root:xnu-3248.20.55~2/RELEASE_X86_64 x86_64
➜  php-7.0.0  uname -p
i386
➜  php-7.0.0  ./configure --prefix=/usr/local/php7 --with-config-file-path=/usr/local/php7/etc --enable-fpm --with-fpm-user=www --with-fpm-group=www --with-mysqli --with-pdo-mysql --with-iconv-dir --with-freetype-dir --with-jpeg-dir --with-png-dir --with-zlib --with-libxml-dir=/usr --enable-xml --disable-rpath --enable-bcmath --enable-shmop --enable-sysvsem --enable-inline-optimization --with-curl --enable-mbregex --enable-mbstring --with-mcrypt --enable-ftp --with-gd --enable-gd-native-ttf --with-openssl=/usr/local/opt/openssl --with-mhash --enable-pcntl --enable-sockets --with-xmlrpc --enable-zip --enable-soap --without-pear --with-gettext=/usr/local/opt/gettext --disable-fileinfo --enable-maintainer-zts

这个通过了。但在make的时候,提示以下错误:

Undefined symbols for architecture x86_64:
  "_PKCS5_PBKDF2_HMAC", referenced from:
      _zif_openssl_pbkdf2 in openssl.o
  "_SSL_CTX_set_alpn_protos", referenced from:
      _php_openssl_setup_crypto in xp_ssl.o
  "_SSL_CTX_set_alpn_select_cb", referenced from:
      _php_openssl_setup_crypto in xp_ssl.o
  "_SSL_get0_alpn_selected", referenced from:
      _php_openssl_sockop_set_option in xp_ssl.o
  "_SSL_select_next_proto", referenced from:
      _server_alpn_callback in xp_ssl.o
  "_TLSv1_1_client_method", referenced from:
      _php_openssl_setup_crypto in xp_ssl.o
  "_TLSv1_1_server_method", referenced from:
      _php_openssl_setup_crypto in xp_ssl.o
  "_TLSv1_2_client_method", referenced from:
      _php_openssl_setup_crypto in xp_ssl.o
  "_TLSv1_2_server_method", referenced from:
      _php_openssl_setup_crypto in xp_ssl.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: *** [sapi/cli/php] Error 1

make -v

GNU Make 3.81
Copyright (C) 2006 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.
There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A
PARTICULAR PURPOSE.

This program built for i386-apple-darwin11.3.0

应该如何解决?试了一些办法还是不行

阅读 17.6k
8 个回答

这里应该是动态链接库的问题,但是我没查到如何更新Mac的动态链接库。
执行 brew list openssl 可以看到当前openssl安装的位置,查不出什么问题来。所以我执行 brew search openssl查看到目前可用的openssl版本,brew remove openssl 删除了当前安装的 --with-openssl=/usr/local/Cellar/openssl/1.0.2d_1/,重装了 brew install openssl098 问题解决了。

这问题我也困扰了一下午,找到了比较靠谱的解决方法:
http://stackoverflow.com/a/31734677
看不懂英文,中文版也有:
https://upliu.net/compile-php-with-opens...

不用像楼上说的那么复杂,只需要
make clean
vim Makefile
按照参考文档里的把几个参数删掉,追加libssl.dylib 和 libcrypto.dylib 的路径,重新make就好了

绝对ok

main/streams/xp_socket.o main/streams/mmap.o main/streams/glob_wrapper.o Zend/zend_language_parser.o Zend/zend_language_scanner.o Zend/zend_ini_parser.o Zend/zend_ini_scanner.o Zend/zend_alloc.o Zend/zend_compile.o Zend/zend_constants.o Zend/zend_dynamic_array.o Zend/zend_dtrace.o Zend/zend_execute_API.o Zend/zend_highlight.o Zend/zend_llist.o Zend/zend_vm_opcodes.o Zend/zend_opcode.o Zend/zend_operators.o Zend/zend_ptr_stack.o Zend/zend_stack.o Zend/zend_variables.o Zend/zend.o Zend/zend_API.o Zend/zend_extensions.o Zend/zend_hash.o Zend/zend_list.o Zend/zend_indent.o Zend/zend_builtin_functions.o Zend/zend_sprintf.o Zend/zend_ini.o Zend/zend_qsort.o Zend/zend_multibyte.o Zend/zend_ts_hash.o Zend/zend_stream.o Zend/zend_iterators.o Zend/zend_interfaces.o Zend/zend_exceptions.o Zend/zend_strtod.o Zend/zend_gc.o Zend/zend_closures.o Zend/zend_float.o Zend/zend_string.o Zend/zend_signal.o Zend/zend_generators.o Zend/zend_objects.o Zend/zend_object_handlers.o Zend/zend_objects_API.o Zend/zend_default_classes.o Zend/zend_execute.o main/internal_functions_cli.o sapi/cgi/cgi_main.o sapi/cgi/fastcgi.o -lresolv -liconv -liconv -lpng -lz -ljpeg -lz -lm -lxml2 -lz -licucore -lm -lxml2 -lz -licucore -lm -lfreetype -lxml2 -lz -licucore -lm -lxml2 -lz -licucore -lm -lxml2 -lz -licucore -lm -lxml2 -lz -licucore -lm /usr/local/opt/openssl/lib/libssl.dylib /usr/local/opt/openssl/lib/libcrypto.dylib -o sapi/cgi/php-cgi
Generating phar.php

Generating phar.phar
PEAR package PHP_Archive not installed: generated phar will require PHP's phar extension be enabled.
clicommand.inc
directorygraphiterator.inc
directorytreeiterator.inc
invertedregexiterator.inc
pharcommand.inc
phar.inc

Build complete.
Don't forget to run 'make test'.

brew install openssl

OSX 10.11不带openssl的头文件了,去Xcode 6.4.dmg里用zip解压拿到头文件放到/usr/include/openssl里在编译即可通过,如果重新编译openssl记得系统自带的不要动,不然重启就挂,当然如果你自己非要重新编译就0.9.8版本,其他版本绝对挂,不说了,说多了都是泪

楼主解决了没有 我也遇到这种情况了

同样的问题

Undefined symbols for architecture x86_64:
  "_PKCS5_PBKDF2_HMAC", referenced from:
      _zif_openssl_pbkdf2 in openssl.o
  "_SSL_CTX_set_alpn_protos", referenced from:
      _php_openssl_setup_crypto in xp_ssl.o
  "_SSL_CTX_set_alpn_select_cb", referenced from:
      _php_openssl_setup_crypto in xp_ssl.o
  "_SSL_get0_alpn_selected", referenced from:
      _php_openssl_sockop_set_option in xp_ssl.o
  "_SSL_select_next_proto", referenced from:
      _server_alpn_callback in xp_ssl.o
  "_TLSv1_1_client_method", referenced from:
      _php_openssl_setup_crypto in xp_ssl.o
  "_TLSv1_1_server_method", referenced from:
      _php_openssl_setup_crypto in xp_ssl.o
  "_TLSv1_2_client_method", referenced from:
      _php_openssl_setup_crypto in xp_ssl.o
  "_TLSv1_2_server_method", referenced from:
      _php_openssl_setup_crypto in xp_ssl.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/libphp7.bundle] Error 1

我编译tegine的时候遇到这样的问题,求解。。。

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
宣传栏