无法在 ruby​​ 1.9.2 上构建 iconv gem

发布于 2024-09-17 00:57:07 字数 4131 浏览 13 评论 0原文

由于奇怪的构建错误,我无法安装“iconv”gem。
我已经从源代码构建了“libiconv”,并将 .h 和 .dylib 链接到了 rvm 的 include 和 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

我如何正确安装和构建它。

谢谢

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 run

gem 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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(8

┼── 2024-09-24 00:57:07

对于它的价值 - 我能够使用 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

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
你げ笑在眉眼 2024-09-24 00:57:07

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

我已经安装了 libiconv 的脚本 w/brew

gem install iconv -- --with-iconv-dir=/usr/local/Cellar/libiconv/1.13 .1

Herp derp

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

权谋诡计 2024-09-24 00:57:07

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

一些建议:

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

,如果您想要/需要安装自己的版本,请确保将其安装在 /usr/local 子树中(它适用于管理员编译的软件,这正是您所需要的)正在做)。因此,您最终应该得到 /usr/local/include/iconv.h/usr/local/lib/libiconv.dylib

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.

日暮斜阳 2024-09-24 00:57:07

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

./configure
make
sudo make install

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

我没有足够的 C-fu 来进一步解释这个问题,但我猜这可能是某种版本不匹配的结果?也许 iconv gem 期望有一些旧版本的 libiconv ?在我用随机版本的 iconv 来修改我的系统之前,我希望得到一些确认。

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.

空心空情空意 2024-09-24 00:57:07

我想我已经找到原因了!
看起来 Iconv gem 尚未兼容 1.9.x,因此无法构建。

I think I have found out why !
Looks like the Iconv gem is not yet 1.9.x compliant, so it will not build.

少跟Wǒ拽 2024-09-24 00:57:07

在 Lion 下,这两行代码有效:

brew 安装 libiconv

brew 链接 libiconv

Under Lion these two lines work:

brew install libiconv

brew link libiconv

默嘫て 2024-09-24 00:57:07

@DarkDust 和 @Vee 的建议组合对我来说是这样的:

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

您可以运行

port contents libiconv

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

A combination of the suggestions by @DarkDust and @Vee does it for me:

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

You can run

port contents libiconv

to that libiconv is now installed under /opt/local/include/ and /opt/local/include/lib. I should also mention that I'm using ruby 1.9.3p286.

白昼 2024-09-24 00:57:07

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

$ rvm pkg install iconv
$ rvm reinstall 1.9.2 --with-iconv-dir=$rvm_path/usr

Try to install the iconv rvm package and then reinstall ruby 1.9.2:

$ rvm pkg install iconv
$ rvm reinstall 1.9.2 --with-iconv-dir=$rvm_path/usr
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文