我的 macOS 上有 openssl,但编译 PHP 时出现错误

我的 macOS 上有 openssl,但编译 PHP 时出现错误

我使用此命令在我的 macOS 上编译 php:

./configure \
  --prefix=/opt/php-7.4.30 \
  --with-config-file-path=/opt/php-7.4.30/etc \
  --with-pdo-mysql=mysqlnd \
  --with-mysqli=mysqlnd \
  --with-libxml-dir \
  --with-gd \
  --with-jpeg-dir \
  --with-png-dir \
  --with-freetype-dir \
  --with-iconv=/opt/homebrew/Cellar/libiconv/1.17 \
  --with-zlib-dir=/opt/homebrew/Cellar/zlib/1.2.12_1 \
  --with-bz2=/opt/homebrew/Cellar/bzip2/1.0.8 \
  --with-openssl=/opt/homebrew/Cellar/openssl@3/3.0.5/\
  --with-curl=/opt/homebrew/Cellar/curl/7.85.0 \
  --enable-soap \
  --enable-mbstring \
  --enable-sockets \
  --enable-exif \
  --with-readline=/opt/homebrew/Cellar/readline/8.1.2 \
  --disable-ipv6

在我的 macOS 中,我确实有/opt/homebrew/Cellar/openssl@3/3.0.5/

 % ls /opt/homebrew/Cellar/openssl@3/3.0.5/
AUTHORS         INSTALL_RECEIPT.json    NEWS            bin         lib
CHANGES         LICENSE         README          include         share

我收到以下错误:

Configuring extensions
checking io.h usability... no
checking io.h presence... no
checking for io.h... no
checking for strtoll... yes
checking for atoll... yes
checking whether to build with LIBXML support... yes
checking for libxml-2.0 >= 2.7.6... yes
checking for OpenSSL support... yes
checking for Kerberos support... no
checking whether to use system default cipher list instead of hardcoded value... no
checking for openssl >= 1.0.1... no
configure: error: Package requirements (openssl >= 1.0.1) were not met:

No package 'openssl' found

Consider adjusting the PKG_CONFIG_PATH environment variable if you
installed software in a non-standard prefix.

Alternatively, you may set the environment variables OPENSSL_CFLAGS
and OPENSSL_LIBS to avoid the need to call pkg-config.
See the pkg-config man page for more details.

編輯-01

在问这个问题之前,我曾尝试过:

export OPENSSL_CFLAGS="/opt/homebrew/Cellar/openssl@3/3.0.5/include" 
export OPENSSL_LIBS="/opt/homebrew/Cellar/openssl@3/3.0.5/lib"

export PKG_CONFIG_PATH=/opt/homebrew/Cellar/openssl@3/3.0.5/lib/pkgconfig:$PKG_CONFIG_PATH

答案1

此错误报告处理了该问题 所有最新版本均无法在 OSX 10.14 Mojave 上构建/安装 #90

为了使 PHP 7.1.32 在 Mojave 上构建,我需要以下配置:

env PATH="$(brew --prefix icu4c)/sbin:$(brew --prefix libiconv)/bin:$(brew --prefix curl)/bin:$(brew --prefix

libxml2) /bin:$(brew --prefix bzip2) /bin:$(brew --prefix bison) /bin:$PATH" CONFIGURE_OPTS="--with-zlib-dir=$(brew --prefix zlib) --with-bz2=$(brew --prefix bzip2) --with-curl=$(brew --prefix curl) --with-iconv=$(brew --prefix libiconv)" PHP_BUILD_CONFIGURE_OPTS="--with-openssl=$(brew --prefix[电子邮件保护])“phpenv 安装 7.1.32

那是[电子邮件保护]已安装,但 openssl@3 未安装。我还需要修补 configure,如所述 https://bbs.archlinux.org/viewtopic.php?pid=1954966#p1954966,或者构建失败:

/var/tmp/php-build/source/7.1.32/ext/intl/collat​​or/collat​​or_sort.c:543:26:错误:使用未声明的标识符“FALSE”collat​​or_sort_internal(FALSE,INTERNAL_FUNCTION_PARAM_PASSTHRU);这是补丁:

diff --git a/configure b/configure
index 78811fa..5a303a0 100755
--- a/configure
+++ b/configure
@@ -45864,7 +45864,7 @@ ac_compiler_gnu=$ac_cv_c_compiler_gnu
     php_cxx_done=yes
   fi
 
-  INTL_COMMON_FLAGS="$ICU_INCS -Wno-write-strings -D__STDC_LIMIT_MACROS -DZEND_ENABLE_STATIC_TSRMLS_CACHE=1"
+  INTL_COMMON_FLAGS="$ICU_INCS -Wno-write-strings -D__STDC_LIMIT_MACROS -DZEND_ENABLE_STATIC_TSRMLS_CACHE=1 -DU_DEFINE_FALSE_AND_TRUE=1"
   if test "$icu_version" -ge "4002"; then
     icu_spoof_src=" spoofchecker/spoofchecker_class.c \
     spoofchecker/spoofchecker.c\

同样的问题在 在 MacOS Catalina 上安装 7.4.7 版本的问题 #100,其中海报选择了使用更简单的解决方案 phpbrew

相关内容