1

我在 Fedora 16 中运行 Ruby 1.9.3p194 和 Rails 3.2.9。当 I 时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 的解决方案。我不知道该怎么办,请帮忙。

编辑 1 结果yum 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
4

4 回答 4

5

终于搞定了,步骤如下:

  • 下载 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 才能使编译工作。)

  • 安装 libiconvsudo make install

  • 安装 nokogiri 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

瞧,它显示了成功消息!

于 2012-12-07T22:17:22.033 回答
5

不需要自己编译,试试运行这个命令:

sudo yum install -y gcc ruby-devel libxml2 libxml2-devel libxslt libxslt-devel

或者:

rvm get head && rvm requirements run force

于 2013-02-11T18:58:54.727 回答
0

尝试:

yum install -y iconv-devel

进而:

gem install nokogiri
于 2012-12-07T19:10:09.023 回答
-1

错误信息指示libiconv is missing。你安装了吗?您可能需要安装libiconvlibiconv-devel打包。

于 2012-12-07T19:02:45.277 回答