引入nokogiri编译错误 - 找不到库/头 [英] Nokogiri Compilation Error - Can't find libraries/headers

查看:201
本文介绍了引入nokogiri编译错误 - 找不到库/头的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

试图安装一个宝石,却找不到头,尽管指定它们:

Trying to install a gem, but it can't find the headers, despite specifying them:

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 文件不存在,所以我不明白为什么这是行不通的。

The /usr/local/include/libxml2/libxml/parser.h file does exist, so I don't see why this isn't working.

编辑:我在CentOS 5.4

I'm on Centos 5.4

推荐答案

如果你深入研究 /usr/lib/ruby/1.8/mkmf.rb 你可以计算出如何模拟这是发生在安装过程中的检查。在我的情况,我可以通过创建 conftest.c 包含称为文件做到这一点:

If you dig into /usr/lib/ruby/1.8/mkmf.rb you can figure out how to simulate the check that's happening during install. In my case I could do this by creating a file called conftest.c containing:

#include <libxml/parser.h>

然后尝试运行被传递到 try_do 函数命令。在我而言,这是:

Then try running the command that gets passed into the try_do function. In my case this was:

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的加载一个想法。

In my case I was missing gcc, which is probably not what you're hitting since you said you compiled from source. But hopefully if you run this command it should give you an idea of why you can't load in libxml2.

如果您有兴趣pre-内置显然 EPEL 拥有的 RubyGems的-引入nokogiri 包。很好的机会,我会走到底这条路线。

If you're interested in pre-built apparently EPEL has a rubygems-nokogiri package. Good chance I'll go this route in the end.

这篇关于引入nokogiri编译错误 - 找不到库/头的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆