我在Fedora16中运行Ruby1.9.3p194和Rails3.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的解决方案我不知道该怎么办,请帮忙。
编辑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
最佳答案
终于成功了,下面是步骤:
下载libiconvwget 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
编译libiconvmake CFLAGS="-O2 -fno-tree-dce -fno-optimize-sibling-calls"
(我必须添加cflags才能使编译生效。)
安装libiconvsudo make install
安装nokogiriCFLAGS="-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
瞧,它显示了成功的信息!
关于ruby-on-rails - 无法在Fedora16中gem安装nokogiri,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/13769183/