Failed to build iconv gem on ruby 1.9.2
Solution 1
I think I have found out why ! Looks like the Iconv gem is not yet 1.9.x compliant, so it will not build.
Solution 2
For what it's worth - I was able to build 1.9.2 p136 using RVM and linking to libiconv I installed with Homebrew. This allowed me to use the JSON gem without problems. I wrote a quick blog post about it here: http://www.v25media.com/blog/read/forcing_ruby_1_9_2_via_rvm_to_use_iconv but the gist of it is:
$ brew install libiconv
$ rvm remove 1.9.2
$ rvm install 1.9.2 --with-iconv-dir=/usr/local/Cellar/libiconv/1.13.1
Solution 3
In my case, I was just installing iconv for mechanize so I could run script
I already had libiconv installed w/ brew
gem install iconv -- --with-iconv-dir=/usr/local/Cellar/libiconv/1.13.1
herp derp
Solution 4
Why/how did you build iconv ? And more importantly, where did you install it ? Because I think gem can find the system libiconv but fails to find the headers because they're not in the normal search paths.
A few suggestions:
Easiest way is probably to use MacPorts and install iconv with that: sudo port install libiconv
Or if you want/need to install your own version, make sure it gets installed in the /usr/local
subtree (it's meant for software that an administrator compiled which is exactly what you're doing). So you should end up with /usr/local/include/iconv.h
and /usr/local/lib/libiconv.dylib
.
Solution 5
I have the exact same problem. My freshly installed OS X 10.6 didn't have iconv
, so I downloaded iconv from http://ftp.gnu.org/gnu/libiconv/ and ran
./configure
make
sudo make install
Installed fine, iconv.h and libiconv.dylib are where they're supposed to be, but gem installation rvm gem install iconv
fails with the same errors.
I don't have enough C-fu in me to interpret the problem any further, but I would guess this could be a result of some sort of version mismatch? Maybe the iconv
gem expects to have some older version of libiconv
? I'd like to get some confirmation either way with this, before I fudge my system up with random versions of iconv
.
Jeremy David
Updated on June 05, 2022Comments
-
Jeremy David over 1 year
I fail to install the 'iconv' gem, because of weird build errors.
I have build the 'libiconv' from source and linked the .h and .dylib into the rvm's include and lib directory. When I rungem install iconv
Gem outputs strange build errors:
Building native extensions. This could take a while...
ERROR: Error installing iconv: ERROR: Failed to build gem native extension. /Users/myusername/.rvm/rubies/ruby-1.9.2-rc2/bin/ruby extconf.rb checking for iconv() in iconv.h... no checking for iconv() in -liconv... yes checking for const of iconv() 2nd argument... no creating Makefile make gcc -I. -I/Users/myusername/.rvm/rubies/ruby-1.9.2-rc2/include/ruby-1.9.1/x86_64-darwin10.4.0 -I/Users/myusername/.rvm/rubies/ruby-1.9.2-rc2/include/ruby-1.9.1/ruby/backward -I/Users/myusername/.rvm/rubies/ruby-1.9.2-rc2/include/ruby-1.9.1 -I. -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE -fno-common -O3 -ggdb -Wextra -Wno-unused-parameter -Wno-parentheses -Wpointer-arith -Wwrite-strings -Wno-missing-field-initializers -Wshorten-64-to-32 -Wno-long-long -fno-common -pipe -o iconv.o -c iconv.c In file included from iconv.c:21: /Users/myusername/.rvm/rubies/ruby-1.9.2-rc2/include/ruby-1.9.1/ruby/backward/st.h:2:2: warning: #warning use "ruby/st.h" instead of bare "st.h" iconv.c:22:20: error: intern.h: No such file or directory iconv.c: In function ‘map_charset’: iconv.c:139: error: ‘struct RHash’ has no member named ‘tbl’ iconv.c:139: error: ‘struct RHash’ has no member named ‘tbl’ iconv.c:142: error: ‘struct RHash’ has no member named ‘tbl’ iconv.c: In function ‘iconv_create’: iconv.c:187: error: ‘struct RString’ has no member named ‘len’ iconv.c:188: error: ‘struct RString’ has no member named ‘len’ iconv.c:190: error: ‘struct RString’ has no member named ‘ptr’ iconv.c:190: error: ‘struct RString’ has no member named ‘ptr’ iconv.c:190: error: ‘struct RString’ has no member named ‘ptr’ iconv.c:190: error: ‘struct RString’ has no member named ‘ptr’ iconv.c:192: error: ‘struct RString’ has no member named ‘ptr’ iconv.c:193: error: ‘struct RString’ has no member named ‘len’ iconv.c: In function ‘iconv_fail’: iconv.c:328: error: ‘struct RString’ has no member named ‘len’ iconv.c: In function ‘iconv_fail_retry’: iconv.c:352: error: ‘ruby_errinfo’ undeclared (first use in this function) iconv.c:352: error: (Each undeclared identifier is reported only once iconv.c:352: error: for each function it appears in.) iconv.c: In function ‘rb_str_derive’: iconv.c:371: error: ‘struct RString’ has no member named ‘ptr’ iconv.c:371: error: ‘struct RString’ has no member named ‘len’ iconv.c:373: error: ‘struct RString’ has no member named ‘ptr’ iconv.c:373: error: ‘struct RString’ has no member named ‘len’ iconv.c:374: error: ‘struct RString’ has no member named ‘ptr’ iconv.c: In function ‘iconv_convert’: iconv.c:418: error: ‘struct RArray’ has no member named ‘len’ iconv.c:418: error: ‘struct RArray’ has no member named ‘ptr’ iconv.c:436: error: ‘struct RString’ has no member named ‘len’ iconv.c:437: error: ‘struct RString’ has no member named ‘ptr’ iconv.c:455: warning: comparison of unsigned expression >= 0 is always true iconv.c:458: warning: comparison between signed and unsigned iconv.c:459: warning: comparison between signed and unsigned iconv.c:491: warning: implicit conversion shortens 64-bit value into a 32-bit value iconv.c:494: warning: implicit conversion shortens 64-bit value into a 32-bit value iconv.c:497: error: ‘struct RArray’ has no member named ‘len’ iconv.c:498: error: ‘struct RArray’ has no member named ‘ptr’ iconv.c:499: error: ‘struct RArray’ has no member named ‘ptr’ iconv.c:501: error: ‘struct RString’ has no member named ‘len’ iconv.c:502: error: ‘struct RString’ has no member named ‘ptr’ iconv.c:514: warning: implicit conversion shortens 64-bit value into a 32-bit value iconv.c: In function ‘iconv_s_convert’: iconv.c:615: error: ‘struct RString’ has no member named ‘len’ make: *** [iconv.o] Error 1 Gem files will remain installed in /Users/myusername/.rvm/gems/ruby-1.9.2-rc2/gems/iconv-0.1 for inspection. Results logged to /Users/myusername/.rvm/gems/ruby-1.9.2-rc2/gems/iconv-0.1/ext/iconv/gem_make.out
How do I make it install and build properly.
Thanks