Ruby 1.9.2和pcap宝石?编译错误 [英] Ruby 1.9.2 and pcap gem? Compiling error

查看:150
本文介绍了Ruby 1.9.2和pcap宝石?编译错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在安装ruby 1.9.2的pcap gem时遇到问题...它在1.8.7下正常工作。任何人都知道发生了什么?

  wuntee @ wuntee:〜$ rvm使用系统
现在使用系统ruby。
wuntee @ wuntee:〜$ ruby​​ -v
ruby​​ 1.8.7(2009-06-12 patchlevel 174)[universal-darwin10.0]
wuntee @ wuntee:〜$ gem install pcap
警告:安装到〜/ .gem是因为/Library/Ruby/Gems/1.8和
/ usr / bin不可写。
警告:您的PATH中没有/Users/wuntee/.gem/ruby/1.8/bin,
gem可执行文件将无法运行。
构建本地扩展。这可能需要一段时间...
成功安装pcap-0.7.0
1个安装的gem
为pcap-0.7.0安装ri文档...
安装RDoc文档pcap-0.7.0 ...
wuntee @ wuntee:〜$ rvm use 1.9.2
使用/Users/wuntee/.rvm/gems/ruby-1.9.2-p180
wuntee @wuntee:〜$ ruby​​ -v
ruby​​ 1.9.2p180(2011-02-18修订版30909)[x86_64-darwin10.6.0]
wuntee @ wuntee:〜$ gem install pcap
Building本地扩展。这可能需要一段时间...
错误:安装pcap时出错:
错误:无法构建gem本机扩展。

/Users/wuntee/.rvm/rubies/ruby-1.9.2-p180/bin/ruby extconf.rb
在-lsocket中检查socket()... no
检查-lxnet中的gethostbyname()...不检查
检查hstrerror()...是
检查pcap.h ...是
检查pcap_open_live()in -lpcap ...是
检查pcap_compile_nopcap()...是
创建Makefile

make
gcc -I。 -I / Users / wuntee / .rvm / rubies / ruby​​-1.9.2-p180 / include / ruby​​-1.9.1 / x86_64-darwin10.6.0 -I / Users / wuntee / .rvm / rubies / ruby​​-1.9.2 -p180 / include / ruby​​-1.9.1 / ruby​​ / backward -I / Users / wuntee / .rvm / rubies / ruby​​-1.9.2-p180 / include / ruby​​-1.9.1 -I。 -DHAVE_HSTRERROR -DHAVE_PCAP_H -DHAVE_PCAP_COMPILE_NOPCAP -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE -fno-common -I / usr / local / include -o icmp_packet.o -c icmp_packet.c
gcc -I。 -I / Users / wuntee / .rvm / rubies / ruby​​-1.9.2-p180 / include / ruby​​-1.9.1 / x86_64-darwin10.6.0 -I / Users / wuntee / .rvm / rubies / ruby​​-1.9.2 -p180 / include / ruby​​-1.9.1 / ruby​​ / backward -I / Users / wuntee / .rvm / rubies / ruby​​-1.9.2-p180 / include / ruby​​-1.9.1 -I。 -DHAVE_HSTRERROR -DHAVE_PCAP_H -DHAVE_PCAP_COMPILE_NOPCAP -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE -fno-common -I / usr / local / include -o ip_packet.o -c ip_packet.c
ip_packet.c:函数'ipp_set_src':
ip_packet.c:117:error:'struct RString'has no member named'ptr'
ip_packet.c:In function'ipp_set_dst':
ip_packet.c:118:error:'struct RString'has没有名为'ptr'的成员
ip_packet.c:函数'new_ipaddr':
ip_packet.c:186:警告:从不同大小的整数转换为指针
ip_packet.c:函数'ipaddr_s_new':
ip_packet.c:203:错误:'struct RString'没有名为'ptr'的成员
ip_packet.c:213:警告:格式不是字符串文本格式参数
ip_packet.c:在函数'ipaddr_s_load'中:
ip_packet.c:320:错误:'struct RString'没有名为'len'的成员
ip_packet.c:324:错误:'struct RString '没有名为'ptr'的成员
make:*** [ip_packet.o] Erro r 1


Gem文件将保留安装在/Users/wuntee/.rvm/gems/ruby-1.9.2-p180/gems/pcap-0.7.0中进行检查。
结果记录到/Users/wuntee/.rvm/gems/ruby-1.9.2-p180/gems/pcap-0.7.0/ext/gem_make.out
wuntee @ wuntee:〜$


解决方案

两个简单的查找和替换步骤...



用RSTRING_PTR(foo)替换RSTRING(foo) - > ptr。使用RSTRING_LEN替换RSTRING)foo) - > len (foo)。



好像你现在可以忽略警告,尽管它可能会在新版本的ruby中破解。



编辑:让它实际工作是一个不同的故事。我花了更多的时间在周末将其追溯到ruby-c的扩展本身,以及一些虚假的电话来捕获任何中断并永远阻止。根据我对OS X的理解,不需要额外的阻止。希望这会很快融入宝石,但同时你可以从这个github帐户获得工作版本这里


I am having trouble installing the pcap gem with ruby 1.9.2... It works fine with 1.8.7. Anyone know whats going on?

wuntee@wuntee:~$ rvm use system
Now using system ruby.
wuntee@wuntee:~$ ruby -v
ruby 1.8.7 (2009-06-12 patchlevel 174) [universal-darwin10.0]
wuntee@wuntee:~$ gem install pcap
WARNING:  Installing to ~/.gem since /Library/Ruby/Gems/1.8 and
      /usr/bin aren't both writable.
WARNING:  You don't have /Users/wuntee/.gem/ruby/1.8/bin in your PATH,
      gem executables will not run.
Building native extensions.  This could take a while...
Successfully installed pcap-0.7.0
1 gem installed
Installing ri documentation for pcap-0.7.0...
Installing RDoc documentation for pcap-0.7.0...
wuntee@wuntee:~$ rvm use 1.9.2
Using /Users/wuntee/.rvm/gems/ruby-1.9.2-p180
wuntee@wuntee:~$ ruby -v
ruby 1.9.2p180 (2011-02-18 revision 30909) [x86_64-darwin10.6.0]
wuntee@wuntee:~$ gem install pcap
Building native extensions.  This could take a while...
ERROR:  Error installing pcap:
    ERROR: Failed to build gem native extension.

        /Users/wuntee/.rvm/rubies/ruby-1.9.2-p180/bin/ruby extconf.rb
checking for socket() in -lsocket... no
checking for gethostbyname() in -lxnet... no
checking for hstrerror()... yes
checking for pcap.h... yes
checking for pcap_open_live() in -lpcap... yes
checking for pcap_compile_nopcap()... yes
creating Makefile

make
gcc -I. -I/Users/wuntee/.rvm/rubies/ruby-1.9.2-p180/include/ruby-1.9.1/x86_64-darwin10.6.0 -I/Users/wuntee/.rvm/rubies/ruby-1.9.2-p180/include/ruby-1.9.1/ruby/backward -I/Users/wuntee/.rvm/rubies/ruby-1.9.2-p180/include/ruby-1.9.1 -I. -DHAVE_HSTRERROR -DHAVE_PCAP_H -DHAVE_PCAP_COMPILE_NOPCAP -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE   -fno-common -I/usr/local/include  -o icmp_packet.o -c icmp_packet.c
gcc -I. -I/Users/wuntee/.rvm/rubies/ruby-1.9.2-p180/include/ruby-1.9.1/x86_64-darwin10.6.0 -I/Users/wuntee/.rvm/rubies/ruby-1.9.2-p180/include/ruby-1.9.1/ruby/backward -I/Users/wuntee/.rvm/rubies/ruby-1.9.2-p180/include/ruby-1.9.1 -I. -DHAVE_HSTRERROR -DHAVE_PCAP_H -DHAVE_PCAP_COMPILE_NOPCAP -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE   -fno-common -I/usr/local/include  -o ip_packet.o -c ip_packet.c
ip_packet.c: In function ‘ipp_set_src’:
ip_packet.c:117: error: ‘struct RString’ has no member named ‘ptr’
ip_packet.c: In function ‘ipp_set_dst’:
ip_packet.c:118: error: ‘struct RString’ has no member named ‘ptr’
ip_packet.c: In function ‘new_ipaddr’:
ip_packet.c:186: warning: cast to pointer from integer of different size
ip_packet.c: In function ‘ipaddr_s_new’:
ip_packet.c:203: error: ‘struct RString’ has no member named ‘ptr’
ip_packet.c:213: warning: format not a string literal and no format arguments
ip_packet.c: In function ‘ipaddr_s_load’:
ip_packet.c:320: error: ‘struct RString’ has no member named ‘len’
ip_packet.c:324: error: ‘struct RString’ has no member named ‘ptr’
make: *** [ip_packet.o] Error 1


Gem files will remain installed in /Users/wuntee/.rvm/gems/ruby-1.9.2-p180/gems/pcap-0.7.0 for inspection.
Results logged to /Users/wuntee/.rvm/gems/ruby-1.9.2-p180/gems/pcap-0.7.0/ext/gem_make.out
wuntee@wuntee:~$ 

解决方案

Two easy find and replace steps...

Replace RSTRING(foo)->ptr with RSTRING_PTR(foo).

Replace RSTRING)foo)->len with RSTRING_LEN(foo).

Seems like you can ignore the warnings for now, although it might break in a newer version of ruby.

Edit: getting it to actually WORK is a different story. I spent the better part of the weekend tracing this down into the ruby-c extension itself and some bogus calls to trap any interrupts and block forever. Based on how I understand this working on OS X, additional blocking shouldn't be required. Hopefully this will pulled into the gem soon, but in the meantime you can get the working version from this github account here

这篇关于Ruby 1.9.2和pcap宝石?编译错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆