pecl install memcache fails on OS X Yosemite with "memcache support requires ZLIB"
Asked Answered
H

2

6

I'm trying to perform a pecl install memcache with XAMPP on OS X Yosemite, but it fails to find zlib, producing this error:

checking for the location of ZLIB... no
checking for the location of zlib... configure: error: memcache support requires ZLIB.

Use --with-zlib-dir= to specify prefix where ZLIB include and library are located

ERROR: `/private/tmp/pear/temp/memcache/configure --enable-memcache-session=yes' failed

How to I install zlib so that this pecl install memcache can succeed?

Huebner answered 19/4, 2015 at 7:10 Comment(5)
Please format the question properlyCon
Please read this: stackoverflow.com/help/formatting. Also, I feel your question is more appropriate on Server Fault. Please consider migrate your question.Bentlee
Clarified the question, formatted the command output and eliminated unnecessary detail so reader doesn't have to scroll, improved title to state actual problemPulverulent
brew install zlib and then try again.Paten
I don't agree about moving this to server fault. OSX is an environment that's commonly used for development therefore developers will face this issue.Siana
S
7
brew install zlib

If you haven't already done so

Next find the zlib headers:

locate zlib.h

You may find you have a few options to choose from.

/Applications/Xcode.app/Contents/Developer/Platforms/ etc

or

/usr/local/Cellar/zlib/1.2.8/include/zlib.h

I use brew wherever I can so I chose the brew version:

brew install php55-memcached --with-zlib-dir=/usr/local/Cellar/zlib/1.2.8/include/zlib.h

I assume passing this flag to pecl will have the same result.

Siana answered 21/7, 2015 at 3:35 Comment(0)
P
2

I had the same issue with another extension (SPX)

checking for zlib header... checking for zlib location... configure: error: spx support requires ZLIB. Use --with-zlib-dir=<DIR> to specify the prefix where ZLIB headers and library are located

I did fix it when running ./configure using the --with-zlib-dir flag. Make sure what you have zlib installed (brew install zlib).

phpize

# replace "./configure" with:
./configure --with-zlib-dir=/usr/local/Cellar/zlib/1.2.13
# or "--with-zlib-dir=/opt/homebrew/Cellar/zlib/1.2.13" for Apple silicon

make
sudo make install
Pixilated answered 16/6, 2021 at 12:18 Comment(1)
Also, this answer https://mcmap.net/q/122495/-can-i-install-the-memcached-php-extension-with-pecl is a longer step-by-step walkthrough for downloading a module and compiling it. (And neither mentions using locate zlib.h to find the correct directory, if anyone is struggling with that.)Bindweed

© 2022 - 2024 — McMap. All rights reserved.