Lab Notes

Things I want to remember how to do.

Ubuntu 12.10: Installing taglib-ruby

July 28, 2013

Back when I was fooling around with Ruby I wrote some code using the ruby-taglib library for manipulating mp3 tags. Later, I went through the process of installing Ubuntu 12.10 from scratch on my main system. Eventually I tried running the old on the new system and discovered that I needed to re-install ruby-taglib and ran into some difficulties.

I’ll start with the punchline for people just looking to get on with it:

$ sudo apt-get install ruby-dev libstdc++6-4.7-dev libtag1-dev g++
$ sudo gem install taglib-ruby libtag1-dev

What follows is all the gory details with the error messages in the hope that helps the poor soul using Google to solve this issue. First, I tried it with none of the above packages installed:

$ sudo gem install taglib-ruby
Building native extensions. This could take a while...
ERROR: Error installing taglib-ruby:
ERROR: Failed to build gem native extension.

/usr/bin/ruby1.9.1 extconf.rb
/usr/lib/ruby/1.9.1/rubygems/custom_require.rb:36:in `require': cannot load such file -- mkmf (LoadError)
from /usr/lib/ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
from /var/lib/gems/1.9.1/gems/taglib-ruby-0.5.2/ext/extconf_common.rb:5:in `<top (required)>'
from /usr/lib/ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
from /usr/lib/ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
from extconf.rb:2:in `<main>'


Gem files will remain installed in /var/lib/gems/1.9.1/gems/taglib-ruby-0.5.2 for inspection.
Results logged to /var/lib/gems/1.9.1/gems/taglib-ruby-0.5.2/ext/taglib_base/gem_make.out

Next I tried installing the just the ruby-dev package:

$ sudo apt-get install ruby-dev
$ sudo gem install taglib-ruby
Building native extensions. This could take a while...
ERROR: Error installing taglib-ruby:
ERROR: Failed to build gem native extension.

/usr/bin/ruby1.9.1 extconf.rb
checking for main() in -lstdc++... no
You must have libstdc++ installed.
*** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of
necessary libraries and/or headers. Check the mkmf.log file for more
details. You may need configuration options.

Provided configuration options:
--with-opt-dir
--with-opt-include
--without-opt-include=${opt-dir}/include
--with-opt-lib
--without-opt-lib=${opt-dir}/lib
--with-make-prog
--without-make-prog
--srcdir=.
--curdir
--ruby=/usr/bin/ruby1.9.1
--with-tag-dir
--without-tag-dir
--with-tag-include
--without-tag-include=${tag-dir}/include
--with-tag-lib
--without-tag-lib=${tag-dir}/lib
--with-stdc++lib
--without-stdc++lib


Gem files will remain installed in /var/lib/gems/1.9.1/gems/taglib-ruby-0.5.2 for inspection.
Results logged to /var/lib/gems/1.9.1/gems/taglib-ruby-0.5.2/ext/taglib_base/gem_make.out

This result was confusing because libstdc++ was installed on the system. I realized I needed the libstdc++ development package:

$ apt-cache search stdc++ | grep dev
lib32gmp-dev - Multiprecision arithmetic library developers tools (32bit)
libgmp-dev - Multiprecision arithmetic library developers tools
libstdc++6-4.4-dev - GNU Standard C++ Library v3 (development files)
libstdc++6-4.6-dev - GNU Standard C++ Library v3 (development files)
libstdc++6-4.7-dev - GNU Standard C++ Library v3 (development files)
libstdc++6-4.5-dev - GNU Standard C++ Library v3 (development files)
libstdc++6-4.6-dev-armel-cross - GNU Standard C++ Library v3 (development files)
libstdc++6-4.6-dev-armhf-cross - GNU Standard C++ Library v3 (development files)
libstdc++6-4.7-dev-armel-cross - GNU Standard C++ Library v3 (development files)
libstdc++6-4.7-dev-armhf-cross - GNU Standard C++ Library v3 (development files)
$ sudo apt-get install libstdc++6-4.7-dev
$ sudo gem install taglib-ruby
Building native extensions. This could take a while...
ERROR: Error installing taglib-ruby:
ERROR: Failed to build gem native extension.

/usr/bin/ruby1.9.1 extconf.rb
checking for main() in -lstdc++... yes
checking for main() in -ltag... no
You must have taglib installed in order to use taglib-ruby.

Debian/Ubuntu: sudo apt-get install libtag1-dev
Fedora/RHEL: sudo yum install taglib-devel
Brew: brew install taglib
MacPorts: sudo port install taglib

*** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of
necessary libraries and/or headers. Check the mkmf.log file for more
details. You may need configuration options.

Provided configuration options:
--with-opt-dir
--with-opt-include
--without-opt-include=${opt-dir}/include
--with-opt-lib
--without-opt-lib=${opt-dir}/lib
--with-make-prog
--without-make-prog
--srcdir=.
--curdir
--ruby=/usr/bin/ruby1.9.1
--with-tag-dir
--without-tag-dir
--with-tag-include
--without-tag-include=${tag-dir}/include
--with-tag-lib
--without-tag-lib=${tag-dir}/lib
--with-stdc++lib
--without-stdc++lib
--with-taglib
--without-taglib


Gem files will remain installed in /var/lib/gems/1.9.1/gems/taglib-ruby-0.5.2 for inspection.
Results logged to /var/lib/gems/1.9.1/gems/taglib-ruby-0.5.2/ext/taglib_base/gem_make.out

And the next piece was the taglib development package:

$ sudo apt-get install libtag1-dev
$ sudo gem install taglib-ruby
Building native extensions. This could take a while...
ERROR: Error installing taglib-ruby:
ERROR: Failed to build gem native extension.

/usr/bin/ruby1.9.1 extconf.rb
checking for main() in -lstdc++... yes
checking for main() in -ltag... yes
creating Makefile

make
compiling taglib_base_wrap.cxx
make: g++: Command not found
make: *** [taglib_base_wrap.o] Error 127


Gem files will remain installed in /var/lib/gems/1.9.1/gems/taglib-ruby-0.5.2 for inspection.
Results logged to /var/lib/gems/1.9.1/gems/taglib-ruby-0.5.2/ext/taglib_base/gem_make.out

And finally we need g++ (how else can we compile C++?):

$ sudo apt-get install g++
$ sudo gem install taglib-ruby
Building native extensions. This could take a while...
Successfully installed taglib-ruby-0.5.2
1 gem installed
Installing ri documentation for taglib-ruby-0.5.2...
Installing RDoc documentation for taglib-ruby-0.5.2...