问题
Error while installing iconv on windows by ruby2.0.0
Error while installing iconv on windows by ruby2.0.0
I'm trying to install the iconv , but when I run the following command:
gem install iconv
my result:
Temporarily enhancing Path to include DevKit...
Building native extensions. This could take a while...
Error : Error installing iconv:
ERROR: Failed to build gem native extension.
C:/Ruby/Ruby200/bin/ruby.exe -r ./siteconf20150217-3212-i8hzmh.rb extconf.rb
checking for rb_enc_get() in ruby/encoding.h... yes
checking for rb_sys_fail_str() in ruby.h... yes
checking for iconv() in iconv.h... no
checking for iconv() in -liconv... no
*** 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.
Provided configuration options:
--with-opt-dir
--without-opt-dir
--with-opt-include
--without-opt-include=${opt-dir}/include
--with-opt-lib
--without-opt-lib=${opt-dir}/lib
--with-make-prog
--without-make-prog
--srcdir=.
--curdir
--ruby=C:/Ruby/Ruby200/bin/ruby
--with-iconv-dir
--without-iconv-dir
--with-iconv-include
--without-iconv-include=${iconv-dir}/include
--with-iconv-lib
--without-iconv-lib=${iconv-dir}/
--enable-config-charset
--disable-config-charset
--with-config-charset
--without-config-charset
--with-iconvlib
--without-iconvlib
extconf failed, exit code 1
please help me!!!! THX.
回答1:
I had this problem this evening (Windows 7, Ruby 1.9.3). The solution in my case was as follows:
Install the "Complete package, except sources" from http://gnuwin32.sourceforge.net/packages/libiconv.htm
Run
gem install iconv -v '1.0.4' -- --with-iconv-dir=/path/to/GnuWin32
If that doesn't work, I also followed the instructions here first: http://donpepeto.com/2014/09/20/fixing-c-libraries-on-your-rubyrails-install-on-windows/ (Copying the contents of /bin, /include and /lib from the GnuWin32 install) They didn't work on their own, but once I'd run the setup, I was able to install the gem, so maybe that helped. I also got an error about a missing .gitignore, but I ignored that, ran gem install... again and it worked.
回答2:
I was facing same issue on windows 10. Thanks @Emma Burrows and @ZeWaren. Following worked for me,
- Install libiconv; http://gnuwin32.sourceforge.net/packages/libiconv.htm
- Copy files from
/include
and/lib
into/bin
folder, for meC:\Program Files (x86)\GnuWin32\bin
- Set PATH (Environment Variable) to
C:\Program Files (x86)\GnuWin32\bin
- Exceute (Tricky one):
gem install iconv -- --with-iconv-dir="C:\Program Files (x86)\GnuWin32\"
and during gem install quickly past files from/bin
intoC:\RailsInstaller\Ruby2.2.0\lib\ruby\gems\2.2.0\gems\iconv-1.0.4\ext\iconv
来源:https://stackoverflow.com/questions/28558578/error-while-installing-iconv-on-windows-by-ruby2-0-0