Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can't install Nokogiri gem, "libxml/parser.h" not found, but its there, why?

I tried to install Nokogiri but I always get an compiling error:

checking for libxml/parser.h... *** extconf.rb failed ***

but, I've installed it and all other dependencies.

I try to give the installer hints like this:

%> gem install nokogiri -- --with-xml2-lib=/usr/lib/ --with-xml2-include=/usr/include/libxml2/

...

checking for libxml/parser.h... *** extconf.rb failed ***

...

but it still doesn't install:

%> find /usr/include/ -name "parser.h"    
/usr/include/libxml2/libxml/parser.h
...

I'm on Ubuntu 11.10.

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Output of:

"dpkg-query -l | grep xml" and "dpkg-query -l | grep xslt"

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

The failure seem to be on the side of GCC:

%> cat hello.c
#include <stdio.h>

main()
{
   printf("Hello World \n");
}

%> gcc hello.c
/usr/lib/gcc/x86_64-linux-gnu/4.6.1/../../../x86_64-linux-gnu/crt1.o: In function `_start':
(.text+0x12): undefined reference to `__libc_csu_fini'
/usr/lib/gcc/x86_64-linux-gnu/4.6.1/../../../x86_64-linux-gnu/crt1.o: In function `_start':
(.text+0x19): undefined reference to `__libc_csu_init'
collect2: ld gab 1 als Ende-Status zurück
like image 463
Manuel Görlich Avatar asked Mar 06 '12 18:03

Manuel Görlich


People also ask

Where is libxml2 located?

If you find any file or directory with the substring libxml2 in /usr/local/include or /usr/local/lib (such as /usr/local/lib/libxml2.so ) then it is already installed.

What is Ruby gem Nokogiri?

Nokogiri (鋸) makes it easy and painless to work with XML and HTML from Ruby. It provides a sensible, easy-to-understand API for reading, writing, modifying, and querying documents. It is fast and standards-compliant by relying on native parsers like libxml2 (C) and xerces (Java).


2 Answers

This will work.

sudo apt-get install libxslt-dev libxml2-dev
gem install nokogiri
like image 84
earlonrails Avatar answered Sep 22 '22 08:09

earlonrails


I just faced the same issue on (cat /etc/centos-release:) CentOS release 6.6 (Final).

sudo yum install -y rubygem-nokogiri

…fixed that problem.

(see: http://www.nokogiri.org/tutorials/installing_nokogiri.html#red_hat___centos)

like image 43
klaus Avatar answered Sep 20 '22 08:09

klaus