I've been asked to launch a site that someone else built. It is a Wordpress shop site that needs Memcached to run, and I've been having troubles getting Memcached and the memcache php plugin working on my local server. Before installing memcached and the memcache PHP plugin, I would get this error:

Fatal error: Class 'Memcache' not found in [Path]wp-content/object-cache.php on line 350

Now that I have memcached and the memcache PHP plugin installed (via Homebrew), I get a "No data received" page, and get this error in my Apache error log:

dyld: lazy symbol binding failed: Symbol not found: _mmc_queue_pop
  Referenced from: /usr/lib/php/extensions/no-debug-non-zts-20090626/memcache.so
  Expected in: flat namespace

dyld: Symbol not found: _mmc_queue_pop
  Referenced from: /usr/lib/php/extensions/no-debug-non-zts-20090626/memcache.so
  Expected in: flat namespace

[Sat May 05 16:38:27 2012] [notice] child pid 26491 exit signal Trace/BPT trap (5)

I've tried looking for that pid in Activity Monitor to no avail, and it changes every time I try to load the page. Also, I can't find anything about _mmc_queue_pop anywhere.

I'm running Mac OSX Lion, PHP ver 5.3.8, Memcached ver 1.4.13, and Memcache PHP plugin ver 3.0.6.

Does anyone know how I can fix this?

Thanks!


Solution 1:

As David mentioned in the comments, when building the memcache plugin, NOT memcached itself, you have to add run configure like this:

MACOSX_DEPLOYMENT_TARGET=10.7 CFLAGS='-fgnu89-inline' LDFLAGS='-fgnu89-inline' CXXFLAGS='-fgnu89-inline' ./configure

That worked perfectly for me.

Solution 2:

I would suggest as a first step to make sure what memcache.so is really linked against. On linux you would use ldd, on OSX it should be otool -L IIRC. This looks like the plugin gets hold of either the wrong one of multiple memcache libraries on the system, or of a version that is incompatible.

Solution 3:

Addendum - El Capitan, php56, php56-memcache 3.0.8

After reading David Schwartz and CourtDemone's answers I still didn't get it, until I read this answer on SO about how to edit a homebrew formula.

I added the following to the formula by running brew edit php56-memcache and pasting in the following lines:

   .  20     safe_phpize
   .  21 
   +  22     ENV['MACOSX_DEPLOYMENT_TARGET'] = '10.11'
   +  23     ENV['CFLAGS'] = '-fgnu89-inline'
   +  24     ENV['LDFLAGS'] = '-fgnu89-inline'
   +  25     ENV['CXXFLAGS'] = '-fgnu89-inline'
   +  26 
   .  27     system "./configure", "--prefix=#{prefix}",
   .  28                           phpconfig
   .  29     system "make"