我在Fedora 16中运行Ruby 1.9.3p194和Rails 3.2.9。当我gem install nokogiri
时,它失败并显示错误消息:
ERROR: Error installing nokogiri:
ERROR: Failed to build gem native extension.
/home/chelseaw/.rvm/rubies/ruby-1.9.3-p194/bin/ruby extconf.rb
checking for libxml/parser.h... yes
checking for libxslt/xslt.h... yes
checking for libexslt/exslt.h... yes
checking for iconv_open() in iconv.h... no
checking for iconv_open() in -liconv... no
checking for iconv_open() in -liconv... no
checking for libiconv_open() in iconv.h... no
checking for libiconv_open() in -liconv... no
checking for libiconv_open() in -liconv... no
-----
libiconv is missing. please visit http://nokogiri.org/tutorials/installing_nokogiri.html for help with installing dependencies.
-----
*** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of
necessary libraries and/or headers. Check the mkmf.log file for more
details. You may need configuration options.
我已经用谷歌搜索了一段时间,但只找到了MacOS的一些解决方案。我不知道该怎么办,请帮忙。
编辑 1yum search iconv
的结果:
mingw32-iconv-debuginfo.noarch : Debug information for package mingw32-iconv
mingw32-iconv-static.noarch : Static version of the MinGW Windows Iconv library
mingw32-win-iconv.noarch : MinGW Windows Iconv library
mingw32-win-iconv-debuginfo.noarch : Debug information for package
: mingw-win-iconv
mingw32-win-iconv-static.noarch : Static version of the MinGW Windows Iconv
: library
perl-Text-Iconv.i686 : Perl interface to iconv() codeset conversion function
perl-Text-Iconv-debuginfo.i686 : Debug information for package perl-Text-Iconv
psiconv-debuginfo.i686 : Debug information for package psiconv
psiconv-devel.i686 : Development files for psiconv
uniconvertor-debuginfo.i686 : Debug information for package uniconvertor
mingw32-iconv.noarch : GNU libraries and utilities for character set conversion
perl-HTML-WikiConverter.noarch : Perl module to convert HTML to wiki markup
perl-HTML-WikiConverter-Markdown.noarch : Convert HTML to Markdown markup
psiconv.i686 : A conversion utility for Psion files
uniconvertor.i686 : Universal vector graphics translator
终于可以工作了,步骤如下:
-
下载 libiconv
wget http://ftp.gnu.org/pub/gnu/libiconv/libiconv-1.11.tar.gz
-
tar -xvzf libiconv-1.11.tar.gz
提取文件 -
输入目录
cd libiconv-1.11
-
配置 libiconv 库
./configure --prefix=/usr/local/libiconv
-
编译 libiconv
make CFLAGS="-O2 -fno-tree-dce -fno-optimize-sibling-calls"
(我必须添加 CFLAGS 才能使编译工作。 -
安装 libiconv
sudo make install
-
安装野木里
CFLAGS="-O2 -fno-tree-dce -fno-optimize-sibling-calls" gem install nokogiri -- --with-iconv-dir=/usr/local/libiconv --with-iconv-lib=/usr/local/libiconv/lib --with-iconv-include=/usr/local/libiconv/include
瞧,它显示了成功的信息!
无需自己编译,请尝试运行以下命令:
sudo yum install -y gcc ruby-devel libxml2 libxml2-devel libxslt libxslt-devel
或:
rvm get head && rvm requirements run force
尝试:
yum install -y iconv-devel
然后:
gem install nokogiri
错误消息指示 libiconv is missing
。你安装过吗?您可能需要安装 libiconv
和 libiconv-devel
包。