Register now and start sharing your code snippets.

How to install the stemmer4r gem on Mac OS X and Linux

Ruby posted 5 months ago by christian

The stemmer4r gem is fubar. Warning draft snippet…

   1  # gem install stemmer4r
   2  Bulk updating Gem source index for: http://gems.rubyforge.org
   3  Building native extensions.  This could take a while...
   4  ERROR:  While executing gem ... (Gem::Installer::ExtensionBuildError)
   5      ERROR: Failed to build gem native extension.
   6  
   7  ruby extconf.rb install stemmer4r
   8  
   9  Gem files will remain installed in /usr/lib/ruby/gems/1.8/gems/stemmer4r-0.6 for inspection.
  10  Results logged to /usr/lib/ruby/gems/1.8/gems/stemmer4r-0.6/ext/stemmer4r/gem_make.out
  11  
  12  
  13  1. Change path of Ruby executable
  14  
  15  cd /usr/lib/ruby/gems/1.8/gems/stemmer4r-0.6/ext/stemmer4r/
  16  vim extconf.rb
  17  
  18  #!/usr/bin/ruby -w
  19  
  20  to
  21  
  22  #ruby -w
  23  
  24  2. Compile libstemmer_c
  25  
  26  cd /usr/lib/ruby/gems/1.8/gems/stemmer4r-0.6/ext/stemmer4r/libstemmer/
  27  make
  28  
  29  3. Compile stemmer4r
  30  
  31  cd /usr/lib/ruby/gems/1.8/gems/stemmer4r-0.6/ext/stemmer4r/
  32  
  33  Change path:
  34  /usr/local/ruby/lib/ruby/1.8/i686-linux/
  35  To:
  36  /usr/lib/ruby/1.8/x86_64-linux/
  37  
  38  Or wherever you have it installed
  39  
  40  ruby extconf.rb
  41  
  42  
  43  4. Build stemmer4r gem
  44  
  45  
  46  gem build stemmer4r.gemspec
  47  
  48  gem install stemmer4r-0.6.gem
  49  
  50  
  51  Problems
  52  
  53  gcc -shared -rdynamic -Wl,-export-dynamic   -L"/usr/lib" -o stemmer4r.so stemmer4r.o libstemmer_c/libstemmer.o  -lruby1.8  -lpthread -ldl -lcrypt -lm   -lc
  54  /usr/bin/ld: libstemmer_c/libstemmer.o(libstemmer.o): relocation R_X86_64_32 against `a local symbol' can not be used when making a shared object; recompile with -fPIC
  55  libstemmer_c/libstemmer.o: could not read symbols: Bad value
  56  collect2: ld returned 1 exit status
  57  make: *** [stemmer4r.so] Error 1
  58  
  59  
  60  Add CFLAGS:
  61  
  62  root@aktagon:/usr/lib/ruby/gems/1.8/gems/stemmer4r-0.6/ext/stemmer4r/libstemmer_c# make
  63  include mkinc.mak
  64  CFLAGS   =  -fPIC
  65  libstemmer.o: $(snowball_sources:.c=.o)
  66          $(AR) -cru $@ $^
  67  

Tagged stemming, stemmer4r, install, osx, linux, gem

Error when installing Mongrel from gem

Shell Script (Bash) posted 7 months ago by marko

I received the following error when installing Mongrel from the gem repository:

   1  marko@x61s:$ sudo gem install mongrel
   2  Updating metadata for 281 gems from http://gems.rubyforge.org
   3  complete
   4  Building native extensions.  This could take a while...
   5  ERROR:  Error installing mongrel:
   6  	ERROR: Failed to build gem native extension.
   7  
   8  /usr/bin/ruby1.8 extconf.rb install mongrel
   9  extconf.rb:1:in `require': no such file to load -- mkmf (LoadError)
  10  	from extconf.rb:1

The fix is to install the ruby development package:

   1  sudo apt-get install ruby1.8-dev

Tagged ruby, gem, mongrel, mkmf (loaderror)