编译PHP make时遇到的问题


编译PHP make时遇到的问题

问题一

1.1 make 报错内容

Undefined symbols for architecture x86_64:
  "_libiconv", referenced from:
      _php_iconv_string in iconv.o
      __php_iconv_strlen in iconv.o
      _zif_iconv_substr in iconv.o
      __php_iconv_strpos in iconv.o
      _zif_iconv_mime_encode in iconv.o
      __php_iconv_appendl in iconv.o
      _php_iconv_stream_filter_append_bucket in iconv.o      ...
  "_libiconv_close", referenced from:
      _php_iconv_string in iconv.o
      __php_iconv_strlen in iconv.o
      _zif_iconv_substr in iconv.o
      __php_iconv_strpos in iconv.o
      _zif_iconv_mime_encode in iconv.o
      __php_iconv_mime_decode in iconv.o
      _php_iconv_stream_filter_factory_create in iconv.o      ...
  "_libiconv_open", referenced from:
      _php_iconv_string in iconv.o
      __php_iconv_strlen in iconv.o
      _zif_iconv_substr in iconv.o
      __php_iconv_strpos in iconv.o
      _zif_iconv_mime_encode in iconv.o
      __php_iconv_mime_decode in iconv.o
      _php_iconv_stream_filter_factory_create in iconv.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

1.2 解决方式

./configure --with-iconv=/usr/local/opt/libiconv
# 修改 Makefile 文件
# 将 `EXTRA_LIBS =` 这一行内的 `-liconv` 替换成 `/usr/local/opt/libiconv/lib/libiconv.dylib`

1.3 参考链接

https://learnku.com/laravel/t/21640

问题二

2.1 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)

2.2 解决方法

执行 export LDFLAGS=-lresolv

2.3 参考链接

http://www.52gl.net/dnwl/bckf/20190319/13022.html

问题三

3.1 make报错内容

dyld: Library not loaded: /usr/local/opt/openssl/lib/libcrypto.1.0.0.dylib
  Referenced from: /Users/pandaliu/dev/php/php-7.2.26/sapi/cli/php
  Reason: image not found
/bin/sh: line 1:  6184 Abort trap: 6          .... > ext/phar/phar.php
make: *** [ext/phar/phar.php] Error 134

3.2 解决方法

# 移除openssl(移除方式可能会有其他版本存在,建议是通过uninstall卸载所有版本)
brew remove openssl
# 卸载所有版本openssl 
brew uninstall --force openssl
# 安装openssl
brew install openssl
# 配置环境变量
echo 'export PATH="/usr/local/opt/openssl/bin:$PATH"' >> ~/.bash_profile

3.3 参考链接

https://www.jianshu.com/p/c6d6a60002e4

问题四

4.1 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)

4.2 解决方法

打开php源码根目录,打开 Makefile 修改 EXTRA_LIBS = 这一行内的 -lcrypto-lssl ,替换成

/usr/local/opt/openssl/lib/libcrypto.dylib

/usr/local/opt/openssl/lib/libssl.dylib

4.3 参考链接

https://jzz.moe/mac-e7-bc-96-e8-af-91php7-e6-97-b6-e5-bc-95-e5-85-a5openssl-e6-97-b6-e7-9a-84-e9-94-99-e8-af-afundefined-symbols-for-architecture-x86_64/


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM