2011-03-29 73 views
2

我在安装ruby 1.9.2的pcap gem时遇到了问题...它在1.8.7下正常工作。任何人都知道发生了什么事?Ruby 1.9.2和pcap宝石?编译错误

[email protected]:~$ rvm use system 
Now using system ruby. 
[email protected]:~$ ruby -v 
ruby 1.8.7 (2009-06-12 patchlevel 174) [universal-darwin10.0] 
[email protected]:~$ 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... 
[email protected]:~$ rvm use 1.9.2 
Using /Users/wuntee/.rvm/gems/ruby-1.9.2-p180 
[email protected]:~$ ruby -v 
ruby 1.9.2p180 (2011-02-18 revision 30909) [x86_64-darwin10.6.0] 
[email protected]:~$ 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 
[email protected]:~$ 

回答

2

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

更换RSTRING(富) - > PTR与RSTRING_PTR(富)。

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

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

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

+0

太棒了!从GitHub安装为我工作。 – 2011-06-11 11:23:10