Installing the memcached Ruby Gem on Solaris
March 3rd, 2010
Gosh this one was quite hard. I was getting errors such as:
rlibmemcached_wrap.c:2074: error: syntax error before ‘bool’ rlibmemcached_wrap.c: In function ‘SWIG_AsVal_bool’: rlibmemcached_wrap.c:2076: error: ‘obj’ undeclared (first use in this function) rlibmemcached_wrap.c:2076: error: (Each undeclared identifier is reported only once rlibmemcached_wrap.c:2076: error: for each function it appears in.) rlibmemcached_wrap.c:2077: error: ‘val’ undeclared (first use in this function) rlibmemcached_wrap.c:2077: error: ‘true’ undeclared (first use in this function) rlibmemcached_wrap.c:2080: error: ‘false’ undeclared (first use in this function)
So to solve this I basically followed these helpful instructions Nick Sellen:
Nick Sellen says (January 27, 2010): I had trouble installing it on my Solaris 10 with 32bit / gcc compiled ruby but managed it with a few modifications to extconf.rb: 1. added "--disable-64bit" to the libmemcached configure arguments 2. added "-std=gnu99" to CFLAGS (the rlibmemcached_wrap.c compilation was failing without that) 3. added an extra -R path for ext/lib - not sure if this was needed actually 4. recreated the rlibmemcached_wrap.c with swig (it removed a bunch of methods, not sure if this will bite me later) 5. added three extra libraries "-lnsl -lsocket -lposix4" to resolve a "symbol getaddrinfo: referenced symbol not found" relocation error with rlibmemcached.so (might only need libsocket)
You might also want to view the extconf.rb modifications directly.
The swig step basically involves downloading, compiling and installing swig to somewhere like /opt/swig, then doing “export SWIG=true” in your shell.
Entry Filed under: General

3 Comments Add your own
1. Ben Summers | March 4th, 2010 at 11:31 am
Ah, the joys of compiling software on Solaris.
One of the beauties of using JRuby rather than the standard Ruby is that you don’t have to worry about this sort of thing. Just find the Java library that you want, and use it from your Ruby code. In most cases, the Java library is higher quality and much faster.
Of course, doing this isn’t so easy when you’re hosting software which already exists. :-(
2. Alasdair | March 4th, 2010 at 11:54 am
How do gems with native extensions work with JRuby? Do you have to avoid using them?
3. Ben Summers | March 4th, 2010 at 9:00 pm
You can’t use native extensions, even if they were supported it’d break the real multi-threading. But all the important ones have java versions instead, eg Mongrel.
isitjruby.com used to have some compatibility info, but it looks like it’s down or it’s been taken off air, given the Joyent holding page.
It’s unlikely to be as much of a problem as you might think, though.
Leave a Comment
Some HTML allowed:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>
Trackback this post | Subscribe to the comments via RSS Feed