Memcached – Libmemcached already built; run ‘rake clean’ first if you need to rebuild.

Trying to install memcached ruby gem on Ubuntu 10.04 Lucid Lynx and I get the error

Libmemcached already built; run ‘rake clean’ first if you need to rebuild.

Fixed this by installing

sudo apt-get install libsasl2-dev
gem uninstall memcached && gem install memcached

Full Error Stacktrace:

sudo gem install memcached
Building native extensions.  This could take a while…
ERROR:  Error installing memcached:
ERROR: Failed to build gem native extension.
/opt/ruby-enterprise-1.8.7-2010.02/bin/ruby extconf.rb
Libmemcached already built; run ‘rake clean’ first if you need to rebuild.
creating Makefile
make
gcc -I. -I/opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/1.8/x86_64-linux -I/opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/1.8/x86_64-linux -I.  -fPIC  -I/opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/gems/1.8/gems/memcached-0.19.7/ext/include  -L/opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/gems/1.8/gems/memcached-0.19.7/ext/lib -g -O2    -g -O2    -c rlibmemcached_wrap.c
rlibmemcached_wrap.c: In function ‘_wrap_MemcachedSt_sasl_callbacks_set’:
rlibmemcached_wrap.c:6678: error: ‘sasl_callback_t’ undeclared (first use in this function)
rlibmemcached_wrap.c:6678: error: (Each undeclared identifier is reported only once
rlibmemcached_wrap.c:6678: error: for each function it appears in.)
rlibmemcached_wrap.c:6678: error: ‘arg2’ undeclared (first use in this function)
rlibmemcached_wrap.c:6678: error: expected expression before ‘)’ token
rlibmemcached_wrap.c:6696: error: expected expression before ‘)’ token
rlibmemcached_wrap.c:6697: error: ‘struct memcached_st’ has no member named ‘sasl_callbacks’
rlibmemcached_wrap.c:6697: error: expected ‘)’ before ‘const’
rlibmemcached_wrap.c:6697: error: expected ‘;’ before ‘arg2’
rlibmemcached_wrap.c: In function ‘_wrap_MemcachedSt_sasl_callbacks_get’:
rlibmemcached_wrap.c:6709: error: ‘sasl_callback_t’ undeclared (first use in this function)
rlibmemcached_wrap.c:6709: error: ‘result’ undeclared (first use in this function)
rlibmemcached_wrap.c:6720: error: expected expression before ‘)’ token
rlibmemcached_wrap.c:6720: error: ‘struct memcached_st’ has no member named ‘sasl_callbacks’
rlibmemcached_wrap.c: In function ‘_wrap_memcached_set_sasl_callbacks’:
rlibmemcached_wrap.c:12030: error: ‘sasl_callback_t’ undeclared (first use in this function)
rlibmemcached_wrap.c:12030: error: ‘arg2’ undeclared (first use in this function)
rlibmemcached_wrap.c:12030: error: expected expression before ‘)’ token
rlibmemcached_wrap.c:12048: error: expected expression before ‘)’ token
rlibmemcached_wrap.c:12049: error: expected ‘)’ before ‘const’
rlibmemcached_wrap.c:12049: error: expected ‘)’ before ‘arg2’
rlibmemcached_wrap.c: In function ‘_wrap_memcached_get_sasl_callbacks’:
rlibmemcached_wrap.c:12131: error: ‘sasl_callback_t’ undeclared (first use in this function)
rlibmemcached_wrap.c:12131: error: ‘result’ undeclared (first use in this function)
rlibmemcached_wrap.c:12142: error: expected expression before ‘)’ token
rlibmemcached_wrap.c: In function ‘Init_rlibmemcached’:
rlibmemcached_wrap.c:13344: error: ‘SASL_OK’ undeclared (first use in this function)
make: *** [rlibmemcached_wrap.o] Error 1
Gem files will remain installed in /opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/gems/1.8/gems/memcached-0.19.7 for inspection.
Results logged to /opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/gems/1.8/gems/memcached-0.19.7/ext/gem_make.out

sudo gem install memcachedBuilding native extensions.  This could take a while…ERROR:  Error installing memcached: ERROR: Failed to build gem native extension.
/opt/ruby-enterprise-1.8.7-2010.02/bin/ruby extconf.rbLibmemcached already built; run ‘rake clean’ first if you need to rebuild.creating Makefile
makegcc -I. -I/opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/1.8/x86_64-linux -I/opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/1.8/x86_64-linux -I.  -fPIC  -I/opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/gems/1.8/gems/memcached-0.19.7/ext/include  -L/opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/gems/1.8/gems/memcached-0.19.7/ext/lib -g -O2    -g -O2    -c rlibmemcached_wrap.crlibmemcached_wrap.c: In function ‘_wrap_MemcachedSt_sasl_callbacks_set’:rlibmemcached_wrap.c:6678: error: ‘sasl_callback_t’ undeclared (first use in this function)rlibmemcached_wrap.c:6678: error: (Each undeclared identifier is reported only oncerlibmemcached_wrap.c:6678: error: for each function it appears in.)rlibmemcached_wrap.c:6678: error: ‘arg2’ undeclared (first use in this function)rlibmemcached_wrap.c:6678: error: expected expression before ‘)’ tokenrlibmemcached_wrap.c:6696: error: expected expression before ‘)’ tokenrlibmemcached_wrap.c:6697: error: ‘struct memcached_st’ has no member named ‘sasl_callbacks’rlibmemcached_wrap.c:6697: error: expected ‘)’ before ‘const’rlibmemcached_wrap.c:6697: error: expected ‘;’ before ‘arg2’rlibmemcached_wrap.c: In function ‘_wrap_MemcachedSt_sasl_callbacks_get’:rlibmemcached_wrap.c:6709: error: ‘sasl_callback_t’ undeclared (first use in this function)rlibmemcached_wrap.c:6709: error: ‘result’ undeclared (first use in this function)rlibmemcached_wrap.c:6720: error: expected expression before ‘)’ tokenrlibmemcached_wrap.c:6720: error: ‘struct memcached_st’ has no member named ‘sasl_callbacks’rlibmemcached_wrap.c: In function ‘_wrap_memcached_set_sasl_callbacks’:rlibmemcached_wrap.c:12030: error: ‘sasl_callback_t’ undeclared (first use in this function)rlibmemcached_wrap.c:12030: error: ‘arg2’ undeclared (first use in this function)rlibmemcached_wrap.c:12030: error: expected expression before ‘)’ tokenrlibmemcached_wrap.c:12048: error: expected expression before ‘)’ tokenrlibmemcached_wrap.c:12049: error: expected ‘)’ before ‘const’rlibmemcached_wrap.c:12049: error: expected ‘)’ before ‘arg2’rlibmemcached_wrap.c: In function ‘_wrap_memcached_get_sasl_callbacks’:rlibmemcached_wrap.c:12131: error: ‘sasl_callback_t’ undeclared (first use in this function)rlibmemcached_wrap.c:12131: error: ‘result’ undeclared (first use in this function)rlibmemcached_wrap.c:12142: error: expected expression before ‘)’ tokenrlibmemcached_wrap.c: In function ‘Init_rlibmemcached’:rlibmemcached_wrap.c:13344: error: ‘SASL_OK’ undeclared (first use in this function)make: *** [rlibmemcached_wrap.o] Error 1

Gem files will remain installed in /opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/gems/1.8/gems/memcached-0.19.7 for inspection.Results logged to /opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/gems/1.8/gems/memcached-0.19.7/ext/gem_make.out

Hope this helps someone else!

Posted on June 28, 2010 at 2:10 pm by Jordan Carter · Permalink
In: Ruby on Rails, Server Config, Ubuntu Tricks · Tagged with: , ,

5 Responses

  1. Written by versus
    on July 3, 2010 at 10:58 am
    Permalink

    1. sudo aptitude install libmemcached-dev libsasl2-dev libmemcached-dbg
    2.sudo rm -rf /usr/lib/ruby/gems/1.8/gems/memcach*
    3.sudo gem install memcached
    4. profit!

  2. Written by kerny
    on July 14, 2010 at 5:03 am
    Permalink

    Thanks for this tip.
    It helps me a lot

  3. Written by Fábio T. da Costa
    on December 2, 2010 at 1:34 am
    Permalink

    Thank you so much!!!!

  4. Written by Dinesh Atoliya
    on March 26, 2011 at 7:49 pm
    Permalink

    Dont Forget to install memcache-client

    $ sudo gem install memcache-client

  5. Written by David
    on January 18, 2012 at 10:29 am
    Permalink

    Thx for the tip!! It helped me to solve a problem with the install of OSM Rails Port!

Leave a Reply