-1

When I run gem install iconv, it fails as follows:

Building native extensions.  This could take a while...
ERROR:  Error installing iconv:
    ERROR: Failed to build gem native extension.

    current directory: /home/myname/local/rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/iconv-1.0.4/ext/iconv
/home/myname/local/rbenv/versions/2.3.1/bin/ruby -r ./siteconf20160802-38989-1ie1z24.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.

I don't know how to fix this. What should I do?

  • Which platform/distribution is this? You seem to be missing a package providing the iconv.h include file. – Lars Haugseth Aug 02 '16 at 13:51
  • I fixed! The two option was needed. --with-iconv-include=/usr/local/include --with-iconv-lib=/usr/local/lib –  Aug 02 '16 at 13:57

1 Answers1

2

If your host is running Ubuntu/Debian:

sudo aptitude install libc6-dev

if Fedora/Redhat:

sudo yum install libc6-devel

Then retry with gem install iconv. All credits go to @lars-haugseth.

Aleksei Matiushkin
  • 119,336
  • 10
  • 100
  • 160