October 31, 2014

Installing memcached-1.4.21 on Mac OS X Yosemite , OS X 10.9.5


For installing memcached in Mac OS you will need to install "libevent" library (libevent 1.1 or higher to deal with a kqueue bug)

Libevent is an 'event notification library' used my memcached.

Installing libevent & memcached 

To manually download the latest stable version of this library visit the below link
http://libevent.org/

To download using curl from Mac OS X terminal use the following command
curl --remote-name --location https://sourceforge.net/projects/levent/files/libevent/libevent-2.0/libevent-2.0.22-stable.tar.gz
If terminal is connected to internet through proxy, you may not be able to download the file. To resolve this try "export https_proxy" command
Example: export https_proxy=http://proxy_ip:proxy_port

Unzip the tar.gz file downloaded using the following command
tar -xzvf libevent-2.0.22-stable.tar.gz
cd libevent-2.0.22-stable
Compile and install the libevent library using the following command

./configure --prefix=/usr/local/libevent-2.0.22 --disable-dependency-tracking --disable-debug-mode
make
sudo make install 

Create a symbolic link for "libevent" using the following command

ln -s libevent-2.0.22 /usr/local/libevent

After installing the dependency 'libevent' it's time to install the memcached

Download the stable memcached-1.4.21 version from memcached website.
http://memcached.org/files/memcached-1.4.21.tar.gz
To download from terminal use the following command
curl --remote-name http://www.memcached.org/files/memcached-1.4.22.tar.gz
Other stable versions of memcached can be downloaded from
http://www.memcached.org/files/
https://code.google.com/p/memcached/wiki/ReleaseNotes

Unzip memcached-1.4.21.tar.gz file using the following command
tar -xzvf memcached-1.4.22.tar.gz
cd  memcached-1.4.22
x commands to exract
v commands to be verbose (display what's happening while executing)

Compile and install using the following commad
./configure --prefix=/usr/local/memcached-1.4.22 --with-libevent=/usr/local/libevent
makesudo make install 
If necessary create symbolic link using the following command
ln -s memcached-1.4.22 /usr/local/memcached


frequent errors:

items.c:1141:28: error: comparison of constant 256 with expression of type 'uint8_t' (aka 'unsigned char') is always true
      [-Werror,-Wtautological-constant-out-of-range-compare]
    assert(it->slabs_clsid < LARGEST_ID);
           ~~~~~~~~~~~~~~~ ^ ~~~~~~~~~~
/usr/include/assert.h:93:25: note: expanded from macro 'assert'
    (__builtin_expect(!(e), 0) ? __assert_rtn(__func__, __FILE__, __LINE__, #e) : (void)0)
                        ^
1 error generated.
make[2]: *** [memcached_debug-items.o] Error 1
make[1]: *** [all-recursive] Error 1

make: *** [all] Error 2

Solution: Follow the above mentioned steps correctly.

Feel free to comment if you are facing any issues.


4 comments :

  1. Got the same error and followed your instructions to a tee

    ReplyDelete
  2. I got the same error, you got some way to fix this problem?

    ReplyDelete
    Replies
    1. Have you tried the steps mentioned and installed libevent ?

      Delete
  3. Anonymous19 July, 2015

    I'm getting the error when installing memcached 1.4.24. Installed 1.4.23 instead.

    ReplyDelete