如何在Windows上安装PCAP的ruby

这一定是一个比较新的问题,但我仍然坚持下去。 我知道这是一个简单的解决scheme。 我做了一些谷歌search,但无法find确切的答案。 这是我得到的错误…

C:\Ruby193\include\ruby-1.9.1\i386-mingw32>gem install pcap Temporarily enhancing PATH to include DevKit... Building native extensions. This could take a while... ERROR: Error installing pcap: ERROR: Failed to build gem native extension. C:/Ruby193/bin/ruby.exe extconf.rb checking for socket() in -lsocket... no checking for gethostbyname() in -lxnet... no checking for hstrerror()... no checking for pcap.h... no *** extconf.rb failed *** Could not create Makefile due to some reason, probably lack of necessary libraries and/or headers. Check the mkmf.log file for more details. You may need configuration options. 

显然我错过了一些图书馆,但我不知道如何得到这些,也不知道试图安装pcap时他们应该位于何处。

mkmf.log

  have_library: checking for socket() in -lsocket... -------------------- no "gcc -o conftest -IC:/Ruby193/include/ruby-1.9.1/i386-mingw32 -IC:/Ruby193/include/ruby-1.9.1/ruby/backward -IC:/Ruby193/include/ruby-1.9.1 -I. -I/usr/local/include conftest.c -L. -LC:/Ruby193/lib -L/usr/local/lib -lmsvcrt-ruby191 -lshell32 -lws2_32 -limagehlp " checked program was: /* begin */ 1: #include "ruby.h" 2: 3: #include <winsock2.h> 4: #include <windows.h> 5: int main() {return 0;} /* end */ "gcc -o conftest -IC:/Ruby193/include/ruby-1.9.1/i386-mingw32 -IC:/Ruby193/include/ruby-1.9.1/ruby/backward -IC:/Ruby193/include/ruby-1.9.1 -I. -I/usr/local/include conftest.c -L. -LC:/Ruby193/lib -L/usr/local/lib -lmsvcrt-ruby191 -lsocket -lshell32 -lws2_32 -limagehlp " c:/users/user/downloads/mingw/bin/../lib/gcc/mingw32/4.5.2/../../../../mingw32/bin/ld.exe: cannot find -lsocket collect2: ld returned 1 exit status checked program was: /* begin */ 1: #include "ruby.h" 2: 3: #include <winsock2.h> 4: #include <windows.h> 5: 6: /*top*/ 7: int main() {return 0;} 8: int t() { void ((*volatile p)()); p = (void ((*)()))socket; return 0; } /* end */ "gcc -o conftest -IC:/Ruby193/include/ruby-1.9.1/i386-mingw32 -IC:/Ruby193/include/ruby-1.9.1/ruby/backward -IC:/Ruby193/include/ruby-1.9.1 -I. -I/usr/local/include conftest.c -L. -LC:/Ruby193/lib -L/usr/local/lib -lmsvcrt-ruby191 -lsocket -lshell32 -lws2_32 -limagehlp " conftest.c: In function 't': conftest.c:8:1: error: too few arguments to function 'socket' c:\users\user\downloads\mingw\bin\../lib/gcc/mingw32/4.5.2/../../../../include/winsock2.h:553:35: note: declared here checked program was: /* begin */ 1: #include "ruby.h" 2: 3: #include <winsock2.h> 4: #include <windows.h> 5: 6: /*top*/ 7: int main() {return 0;} 8: int t() { socket(); return 0; } /* end */ -------------------- have_library: checking for gethostbyname() in -lxnet... -------------------- no "gcc -o conftest -IC:/Ruby193/include/ruby-1.9.1/i386-mingw32 -IC:/Ruby193/include/ruby-1.9.1/ruby/backward -IC:/Ruby193/include/ruby-1.9.1 -I. -I/usr/local/include conftest.c -L. -LC:/Ruby193/lib -L/usr/local/lib -lmsvcrt-ruby191 -lxnet -lshell32 -lws2_32 -limagehlp " c:/users/user/downloads/mingw/bin/../lib/gcc/mingw32/4.5.2/../../../../mingw32/bin/ld.exe: cannot find -lxnet collect2: ld returned 1 exit status checked program was: /* begin */ 1: #include "ruby.h" 2: 3: #include <winsock2.h> 4: #include <windows.h> 5: 6: /*top*/ 7: int main() {return 0;} 8: int t() { void ((*volatile p)()); p = (void ((*)()))gethostbyname; return 0; } /* end */ "gcc -o conftest -IC:/Ruby193/include/ruby-1.9.1/i386-mingw32 -IC:/Ruby193/include/ruby-1.9.1/ruby/backward -IC:/Ruby193/include/ruby-1.9.1 -I. -I/usr/local/include conftest.c -L. -LC:/Ruby193/lib -L/usr/local/lib -lmsvcrt-ruby191 -lxnet -lshell32 -lws2_32 -limagehlp " conftest.c: In function 't': conftest.c:8:1: error: too few arguments to function 'gethostbyname' c:\users\user\downloads\mingw\bin\../lib/gcc/mingw32/4.5.2/../../../../include/winsock2.h:555:57: note: declared here checked program was: /* begin */ 1: #include "ruby.h" 2: 3: #include <winsock2.h> 4: #include <windows.h> 5: 6: /*top*/ 7: int main() {return 0;} 8: int t() { gethostbyname(); return 0; } /* end */ -------------------- have_func: checking for hstrerror()... -------------------- no "gcc -o conftest -IC:/Ruby193/include/ruby-1.9.1/i386-mingw32 -IC:/Ruby193/include/ruby-1.9.1/ruby/backward -IC:/Ruby193/include/ruby-1.9.1 -I. -I/usr/local/include conftest.c -L. -LC:/Ruby193/lib -L/usr/local/lib -lmsvcrt-ruby191 -lshell32 -lws2_32 -limagehlp " conftest.c: In function 't': conftest.c:8:53: error: 'hstrerror' undeclared (first use in this function) conftest.c:8:53: note: each undeclared identifier is reported only once for each function it appears in checked program was: /* begin */ 1: #include "ruby.h" 2: 3: #include <winsock2.h> 4: #include <windows.h> 5: 6: /*top*/ 7: int main() {return 0;} 8: int t() { void ((*volatile p)()); p = (void ((*)()))hstrerror; return 0; } /* end */ "gcc -o conftest -IC:/Ruby193/include/ruby-1.9.1/i386-mingw32 -IC:/Ruby193/include/ruby-1.9.1/ruby/backward -IC:/Ruby193/include/ruby-1.9.1 -I. -I/usr/local/include conftest.c -L. -LC:/Ruby193/lib -L/usr/local/lib -lmsvcrt-ruby191 -lshell32 -lws2_32 -limagehlp " C:\Users\USER\AppData\Local\Temp\ccbjKHSc.o:conftest.c:(.text+0x19): undefined reference to `hstrerror' collect2: ld returned 1 exit status checked program was: /* begin */ 1: #include "ruby.h" 2: 3: #include <winsock2.h> 4: #include <windows.h> 5: 6: /*top*/ 7: int main() {return 0;} 8: int t() { hstrerror(); return 0; } /* end */ -------------------- have_header: checking for pcap.h... -------------------- no "gcc -E -IC:/Ruby193/include/ruby-1.9.1/i386-mingw32 -IC:/Ruby193/include/ruby-1.9.1/ruby/backward -IC:/Ruby193/include/ruby-1.9.1 -I. -I/usr/local/include conftest.c -o conftest.i" conftest.c:5:18: fatal error: pcap.h: No such file or directory compilation terminated. checked program was: /* begin */ 1: #include "ruby.h" 2: 3: #include <winsock2.h> 4: #include <windows.h> 5: #include <pcap.h> /* end */ -------------------- 

Solutions Collecting From Web of "如何在Windows上安装PCAP的ruby"