Nokogiri编译错误 - 找不到库/标题

时间:2010-08-13 22:51:38

标签: c ruby rubygems compilation

尝试安装gem,但无法找到标题,尽管指定了它们:

sudo gem install nokogiri -- --with-xml2-lib=/usr/local/lib --with-xml2-include=/usr/local/include/libxml2  --with-xml2-include=/usr/local/include/libxml2  --with-xslt-include=/usr/local/include/libxslt
Building native extensions.  This could take a while...
ERROR:  Error installing nokogiri:
    ERROR: Failed to build gem native extension.

/usr/bin/ruby extconf.rb --with-xml2-lib=/usr/local/lib --with-xml2-include=/usr/local/include/libxml2 --with-xml2-include=/usr/local/include/libxml2 --with-xslt-include=/usr/local/include/libxslt
checking for #include <libxml/parser.h>
... no
-----
libxml2 is missing.  please visit http://nokogiri.org/tutorials/installing_nokogiri.html for help with installing dependencies.

/usr/local/include/libxml2/libxml/parser.h文件确实存在,所以我不明白为什么这不起作用。

编辑:我在Centos 5.4

1 个答案:

答案 0 :(得分:1)

如果你深入研究/usr/lib/ruby/1.8/mkmf.rb,你可以弄清楚如何模拟安装过程中发生的检查。在我的情况下,我可以通过创建一个名为conftest.c的文件来完成此操作,其中包含:

#include <libxml/parser.h>

然后尝试运行传递给try_do函数的命令。就我而言,这是:

gcc -E -I. -I/usr/lib64/ruby/1.8/x86_64-linux -I. -I-I-I/opt/local/include -I-I-I/usr/local/include -I-I-I/usr/include -I-I-I/usr/include -I-I-I/usr/include/libxml2 -I/opt/local/include/libxml2 -I/usr/local/include/libxml2 -I-I/opt/local/include -I-I/usr/local/include -I-I/usr/include -I-I/usr/include -I-I/usr/include/libxml2 -I/opt/local/include -I/usr/local/include -I/usr/include -I/usr/include -I/usr/include/libxml2   -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic -fno-strict-aliasing  -fPIC  -g -DXP_UNIX -O3 -Wall -Wcast-qual -Wwrite-strings -Wconversion -Wmissing-noreturn -Winline  conftest.c -o conftest.i

在我的情况下,我错过了gcc,这可能不是你所说的,因为你说你是从源代码编译的。但希望如果你运行这个命令,它应该让你知道为什么你不能加载libxml2。

如果您对预建的兴趣显然EPEL有一个rubygems-nokogiri包。很有可能我最终会走这条路。