libxml-ruby and extconf failure - need libm

16 Dec 2008

I was installing libxml-ruby today and got a weird error:

extconf failure: need libm

Hm, ok, libm is supplied by the glibc-devel RPM, which is installed and there it is:

$ ls -l  /usr/lib/libm.a 
-rw-r--r--  1 root root 449902 Apr 15  2008 /usr/lib/libm.a
$ rpm -qf /usr/lib/libm.a
glibc-devel-2.3.4-2.41

After flailing around for a bit I start actually looking at libxml-ruby's ext/libxml/extconf.rb. Here's the relevant bit around line 50:

unless have_library('m', 'atan')
  # more checks
end

Ok, so, have_library comes from mkmf.rb, and that method does this:

try_func(func, libs, headers, &b)

And what does try_func do? It writes out a small C program that calls that specific function and tries to compile and link it. So that should work unless.... doh, GCC isn't installed! A quick yum install gcc and everything works.

I think it took me so long to figure out what was happening because I was expecting a "libxml2-devel not found" kind of error, and if GCC wasn't installed I'd expect to get a "no C compiler found" error. Anyhow, hope this helps someone.