c - Nokogiri 编译错误 - 找不到库/ header

标签 c ruby rubygems compilation

尝试安装 gem,但它找不到 header ,尽管指定了 header :

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 上

最佳答案

如果您深入研究 /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包裹。很有可能我最后会走这条路。

关于c - Nokogiri 编译错误 - 找不到库/ header ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3481177/

相关文章:

c - 使用 scanf 在 C 中向后打印字符串

c - 我想打印一个元素在 C 中的随机数数组中重复的次数

ruby-on-rails - 如何在设计生成的注册表中添加一个额外的字段?

mysql - rake db :migrate - Rake aborted! 访问被拒绝

c - 如何让这个C函数连续执行?

c - 如何将指向动态分配数组的指针作为函数参数传输

ruby - 错误 : "Could not find rake", 尚未安装 Rake

ruby-on-rails - 如何使用 Ruby on Rails 将普通台式机变成服务器来托管网站?

javascript - 使用 Ajax Rails 4 保存后的操作

windows - Windows 上的 Gem 更新 - 它坏了吗?