5

由于奇怪的构建错误,我无法安装“iconv”gem。
我已经从源代码构建了“libiconv”,并将 .h 和 .dylib 链接到 rvm 的包含和 lib 目录中。当我跑

gem install iconv

Gem 输出奇怪的构建错误:

构建原生扩展。这可能需要一段时间...

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

如何使其正确安装和构建。

谢谢

4

8 回答 8

8

对于它的价值 - 我能够使用 RVM 构建 1.9.2 p136 并链接到我使用 Homebrew 安装的 libiconv。这让我可以毫无问题地使用 JSON gem。我在这里写了一篇关于它的快速博客文章:http ://www.v25media.com/blog/read/forcing_ruby_1_9_2_via_rvm_to_use_iconv但它的要点是:

$ brew install libiconv
$ rvm remove 1.9.2
$ rvm install 1.9.2 --with-iconv-dir=/usr/local/Cellar/libiconv/1.13.1
于 2011-01-30T20:22:02.820 回答
6

就我而言,我只是为 mechanize 安装 iconv,这样我就可以运行脚本

我已经用 brew 安装了 libiconv

gem install iconv -- --with-iconv-dir=/usr/local/Cellar/libiconv/1.13.1

疱疹病毒

于 2011-02-28T23:36:34.267 回答
3

为什么/如何构建 iconv ?更重要的是,你在哪里安装它?因为我认为 gem 可以找到系统 libiconv 但无法找到标头,因为它们不在正常的搜索路径中。

几点建议:

最简单的方法可能是使用MacPorts并安装 iconv:sudo port install libiconv

或者,如果您想要/需要安装自己的版本,请确保将其安装在/usr/local子树中(它适用于管理员编译的软件,这正是您正在做的事情)。所以你应该以/usr/local/include/iconv.hand结束/usr/local/lib/libiconv.dylib

于 2010-09-01T08:24:40.340 回答
1

我有完全一样的问题。我新安装的 OS X 10.6 没有iconv,所以我从http://ftp.gnu.org/gnu/libiconv/下载了 iconv并运行

./configure
make
sudo make install

安装得很好,iconv.h 和 libiconv.dylib 是它们应该在的位置,但是 gem 安装rvm gem install iconv失败并出现相同的错误。

我没有足够的 C-fu 来进一步解释这个问题,但我猜这可能是某种版本不匹配的结果?也许iconvgem 期望有一些旧版本的libiconv? 在我用随机版本的iconv.

于 2010-09-24T10:13:37.743 回答
1

我想我已经找到原因了!看起来 Iconv gem 还不兼容 1.9.x,所以它不会构建。

于 2010-09-24T12:12:13.900 回答
0

在 Lion 下,这两行有效:

酿造安装 libiconv

酿造链接 libiconv

于 2011-12-11T09:08:53.457 回答
0

@DarkDust 和 @Vee 的建议组合为我做到了:

sudo port install libiconv
gem install iconv -- --with-iconv-dir=/opt/local

你可以跑

port contents libiconv

libiconv现在安装在/opt/local/include/and下/opt/local/include/lib。我还应该提到我正在使用 ruby​​ 1.9.3p286。

于 2013-03-20T17:33:11.910 回答
-1

尝试安装 iconv rvm 包,然后重新安装 ruby​​ 1.9.2:

$ rvm pkg install iconv
$ rvm reinstall 1.9.2 --with-iconv-dir=$rvm_path/usr
于 2012-03-16T07:58:07.523 回答