34

I am trying to build the memcached extension on OS X 10.9 Mavericks for use with the built in PHP 5.4, initially I tried pecl install memcached but that threw the following.

checking for zlib location... configure: error: memcached support requires ZLIB. Use --with-zlib-dir=<DIR> to specify the prefix where ZLIB headers and library are located
ERROR: `/private/tmp/pear/install/memcached/configure' failed

So I created a tmp directory and executed pecl download memcached, unzipped the code and cd'd to the appropriate directory.

Trying to phpize it returned the following:

grep: /usr/include/php/main/php.h: No such file or directory
grep: /usr/include/php/Zend/zend_modules.h: No such file or directory
grep: /usr/include/php/Zend/zend_extensions.h: No such file or directory
Configuring for:
PHP Api Version:        
Zend Module Api No:     
Zend Extension Api No:  

I had brew installed zlib a while ago and pointed ./configure at my installation. ./configure --with-zlib-dir=/usr/local/Cellar/zlib/1.2.8 I was greeted with the following error message:

checking for session includes... configure: error: Cannot find php_session.h

So now I'm wondering the best course of action here... /usr/include/ doesn't exist at all... is this a Mavericks thing? I don't remember having this problem in 10.8 at all.

I could try brew installing php-devel but I presume that isn't going to be the right version of what I need? Any help would be greatly appreciated here

Update

locate php_session.h reveals

/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/usr/include/php/ext/session/php_session.h

should I just ln -s this to the expected location or is there some way to do this via XCode? I have the command line tools installed...

donatJ
  • 3,105
  • 3
  • 32
  • 51

4 Answers4

99

run xcode-select --install to install the XCode5 Command Line Tools, then sudo pecl install memcache. You should be good to go.

Ty W
  • 6,694
  • 4
  • 28
  • 36
afessler
  • 1,374
  • 1
  • 10
  • 8
  • I'm receiving xcode-select: error: invalid argument 'fixes' Usage: xcode-select [options] – donatJ Oct 23 '13 at 04:05
  • 1
    Holy cow, this worked for me too after an hour of searching. Just for Google sake - this also solved a problem of trying to install apc and getting the error message: /private/tmp/pear/install/APC/apc.h:61:10: fatal error: 'php.h' file not found. – Jason Hoekstra Nov 03 '13 at 05:12
  • 1
    If code-select --install doesn't work for you, you can download them as follows: Open up Xcode In the application menu item "Xcode" select Open Developer Tool > More Developer Tools... This takes you to a site with a bunch of software. Go ahead and download and install "Command Line Tools (OS X Mavericks) for Xcode - Late October 2013". (Copied from https://discussions.apple.com/message/23548005#23548005) – Jonny White Jan 29 '14 at 21:16
  • I am install `php-protocolbuffers` and getting `php.h` not foud. `xcode-select` already present – Volatil3 Apr 02 '16 at 07:04
5

After install XCode5 Command Line Tools as afessler sugest (xcode-select --install) I couldn't do the "sudo pecl install memcache" because pecl was missing. I had to install PEAR and PECL following this guide: http://techtastico.com/post/como-instalar-pear-y-pecl-en-os-x-mavericks/. Then all worked good. Thanks!

haroK
  • 51
  • 1
3

I had this problem and it was due to MAMP not having all the PHP sources.

I found this really helpful solution that explains how to download and configure them: https://stackoverflow.com/a/11175197/369326

Note that the MAMP components doesn't include the extras for any versions of PHP higher than php 5.4.10 but you can download the extras from http://php.net/releases.

Community
  • 1
  • 1
Jonny White
  • 875
  • 10
  • 21
0

As said above but not using xcode install Try installing pecl manually:

  curl -O http://pear.php.net/go-pear.phar 
  sudo php -d detect_unicode=0 go-pear.phar 

and then:

 sudo pecl install memcache

See more at: http://jason.pureconcepts.net/2012/10/install-pear-pecl-mac-os-x/#sthash.x2LKdqj6.dpuf

Julio Marins
  • 10,039
  • 8
  • 48
  • 54