问题描述
这一定是一个相对较新的问题,但我仍然被卡住了.我知道有一个简单的解决方案.我已经做了一些谷歌搜索,但找不到确切的答案.这是我得到的错误...
This must be a relatively newb question but I am still stuck. I know there is a simple solution to this. I've done some googling but could not find an exact answer. Here is the error I get...
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 时它们应该位于何处.
Clearly I am missing some libraries but I not know how to get these nor do I know where they should be located when attempting to install 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 */
--------------------
推荐答案
最终的解决方案是不使用似乎已经过时的 pcap rub.
The end solution was to not use pcap rub which seems to be fairly outdated.
我尝试了 PCAP rub 并继续遇到问题.您可以关注 thread 在这里 Jonm 最终帮助我启动和运行.
I tried PCAP rub and continued to run into issues. You can follow the thread here where Jonm ultimately helped me to get up and running.
这篇关于如何在 Windows 上为 ruby 安装 PCAP的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!