我在装有 Apple 芯片的 Mac 上使用 Homebrew 安装了 PHP、zlib 和 memcached。我正在尝试使用
安装 PHP 的 memcached 扩展sudo pecl install memcached
当它提示我
zlib directory [no] :
时,我指定了"/opt/homebrew/opt/zlib/include"
我已确认此目录包含文件 zlib.h 和 zconf.h。
brew info zlib
也告诉我
For compilers to find zlib you may need to set:
export LDFLAGS="-L/opt/homebrew/opt/zlib/lib"
export CPPFLAGS="-I/opt/homebrew/opt/zlib/include"
For pkg-config to find zlib you may need to set:
export PKG_CONFIG_PATH="/opt/homebrew/opt/zlib/lib/pkgconfig"
所以我似乎为 zlib 提供了正确的路径。但是,运行
sudo pecl install memcached
会抛出以下错误:
checking whether to use system FastLZ library... no
checking for ZLIB... yes, shared
checking for pkg-config... /opt/homebrew/bin/pkg-config
configure: error: Can't find ZLIB headers under "/opt/homebrew/opt/zlib/include"
ERROR: `/private/tmp/pear/temp/memcached/configure --with-php-config=/opt/homebrew/opt/php/bin/php-config --with-libmemcached-dir=no --with-zlib-dir=/opt/homebrew/opt/zlib/include --with-system-fastlz=no --enable-memcached-igbinary=no --enable-memcached-msgpack=no --enable-memcached-json=no --enable-memcached-protocol=no --enable-memcached-sasl=no --enable-memcached-session=no' failed
我该如何解决这个问题?
我有同样的问题,并设法让它在 Mac 上使用路径工作:
/opt/homebrew/opt/zlib
不是“/opt/homebrew/opt/zlib/include”,尽管从技术上讲这是包含标题的文件夹,但错误消息具有误导性。