Ruby 1.9.2 和 pcap gem?编译错误
我在使用 ruby 1.9.2 安装 pcap gem 时遇到问题...它在 1.8.7 上运行良好。有人知道发生了什么事吗?
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:~$
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:~$
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
两个简单的查找和替换步骤...
将 RSTRING(foo)->ptr 替换为 RSTRING_PTR(foo)。
将 RSTRING)foo)->len 替换为 RSTRING_LEN(foo)。
看起来你现在可以忽略这些警告,尽管它可能会在较新版本的 ruby 中崩溃。
编辑:让它真正发挥作用是另一回事。我花了周末的大部分时间追踪这个问题到 ruby-c 扩展本身以及一些虚假调用来捕获任何中断并永远阻塞。根据我对 OS X 上工作的理解,不需要额外的阻止。希望这很快就会被引入 gem,但与此同时,您可以从这个 github 帐户此处<获取工作版本/a>
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
http://rubygems.org/gems/pcap 可能只是与 1.9 不兼容
看起来那个项目不再维护。
也许 http://rubygems.org/gems/pcaprub 会更适合你。
http://rubygems.org/gems/pcap is probably just not compatible with 1.9
It seems like that project isn't being maintained anymore.
Maybe http://rubygems.org/gems/pcaprub would work better for you.