Hi everyone. I have been having issues installing a few gems. PCAP is
one of them. I’ll admit that my troubleshooting abilities are probably
not as up to par as some of the other folks here. Programing and ruby
are a side hobby. I have much to learn.
Here is the error I get when installing pcap
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.
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.
Even when trying to override the WinCap header and library locations it
fails. If I make a new extconf.rb, extconf_a.rb, and hardcode the Pcap
header and library folders the message, “checking for pcap.h” succeeds
but the other checks continue to fail and Make as well fails.
Thanks Jon. I actually did have the wincap libraries and headers
installed. I tried using the “–with-pcap-includedir” argument. You are
right that pcap is fairly old. I tried pcaprub and also and ran into
issues.
I have the wincap lib and headers in C:\WpdPack. That is exactly where
extconf.rb is looking.
C:\Users\user>gem install pcaprub
Temporarily enhancing PATH to include DevKit…
Building native extensions. This could take a while…
ERROR: Error installing pcaprub:
ERROR: Failed to build gem native extension.
C:/Ruby192/bin/ruby.exe extconf.rb
[*] Running checks for pcaprub code…
platform is i386-mingw32
checking for main() in -lws2_32… yes
checking for main() in -liphlpapi… yes
checking for windows.h… yes
checking for winsock2.h… yes
checking for iphlpapi.h… yes
checking for pcap_open_live() in -lwpcap… no
checking for pcap_setnonblock() in -lwpcap… no
creating Makefile
make
gcc -I. -IC:/Ruby192/include/ruby-1.9.1/i386-mingw32
-I/C/Ruby192/include/ruby-1
.9.1/ruby/backward -I/C/Ruby192/include/ruby-1.9.1 -I. -DHAVE_WINDOWS_H
-DHAVE_W
INSOCK2_H -DHAVE_IPHLPAPI_H -O3 -g -Wextra -Wno-unused-parameter
-Wno-parenth
eses -Wpointer-arith -Wwrite-strings -Wno-missing-field-initializers
-Wno-long-l
ong -o pcaprub.o -c pcaprub.c
pcaprub.c:8:18: fatal error: pcap.h: No such file or directory
compilation terminated.
make: *** [pcaprub.o] Error 1
Gem files will remain installed in
C:/Ruby192/lib/ruby/gems/1.9.1/gems/pcaprub-0
.11.2 for inspection.
Results logged to
C:/Ruby192/lib/ruby/gems/1.9.1/gems/pcaprub-0.11.2/ext/pcaprub
/gem_make.out
Hi everyone. I have been having issues installing a few gems. PCAP is
one of them. I’ll admit that my troubleshooting abilities are probably
not as up to par as some of the other folks here. Programing and ruby
are a side hobby. I have much to learn.
Here is the error I get when installing pcap
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.
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.
Looks like you need the Windows version of libpcap headers/lib for this
to have any chance to work.
so once you’ve installed WinPcap you should be able to try to build the
pcap gem again using something similar to the following but using the
dirs from your WinPcap install:
I’ve not tried installing pcap on Win7 with 1.9.3 but I suspect none of
this will work for you because the pcap 0.7.0 version is from 12/2009
(project may be dead) and it’s README says it requires ruby 1.4.x.
If you try all these ideas and still can’t get things to work (and no
one responds with a solution here) join us over at the RubyInstaller
list http://groups.google.com/group/rubyinstaller as Luis and others may
be able to help.
This should work. Unfortunately pcaprub was last updated in 2010. Know
of any other good pcap libs for ruby?
Sadly my WinPcap experience is limited to what Wireshark hides from me.
That said, I’ve just downloaded the WinPcap dev pack from WinPcap · Developer Resources and will hopefully find time this
weekend to get the pcap and packetfu gems to work on my Win7 32bit
w/1.9.3 system.
From the thread I notice your pcap errors were with 1.9.3 but your pcaprub failures were with 1.9.2.
How about starting a gist with all your system details, PATH, and
failure logs?
I ran into a little problem on step 2. Since pcaprub never actually
installs I cannot unpack it. I tried to “gem fetch” followed by a gem
unpack. This worked except that the output dir was empty.
So instead I did a gem install pcaprub --install-dir
“C:\users\user\downloads” and it placed it into the pcaprub-0.11.2
folder.
I then proceeded to make the changes you suggested.
When running the gem build command I got a new error.
C:\Users\user\Downloads\pcaprub-0.11.2>gem install pcaprub-0.11.3.a1.gem
– w
ith-pcap-dir=c:/devlibs/wincap
Temporarily enhancing PATH to include DevKit…
Building native extensions. This could take a while…
ERROR: Error installing pcaprub-0.11.3.a1.gem:
ERROR: Failed to build gem native extension.
C:/Ruby192/bin/ruby.exe extconf.rb
with-pcap-dir=c:/devlibs/wincap
[*] Running checks for pcaprub code…
platform is i386-mingw32
checking for main() in -lws2_32… yes
checking for main() in -liphlpapi… yes
checking for windows.h… yes
checking for winsock2.h… yes
checking for iphlpapi.h… yes
checking for pcap_open_live() in -lwpcap… no
checking for pcap_setnonblock() in -lwpcap… no
creating Makefile
Gem files will remain installed in
C:/Ruby192/lib/ruby/gems/1.9.1/gems/pcaprub-0
.11.3.a1 for inspection.
Results logged to
C:/Ruby192/lib/ruby/gems/1.9.1/gems/pcaprub-0.11.3.a1/ext/pcap
rub/gem_make.out
C:\Users\user\Downloads\pcaprub-0.11.2>
The error being
pcaprub.c:8:18: fatal error: pcap.h: No such file or directory
Which I assume is what ultimately fixed the issue?
Glad to hear it’s working so far and interested on whether it really
grabs works when grabbing packet info.
The -I and -L to $CFLAGS basically tells the DevKit toolchain
(MSYS/MinGW based) where to look for the WinPcap headers and libraries
when building the pcaprub extension. A nit, but the -I option probably
should have been appended to $INCFLAGS.
The -DWIN32 is needed because both the pcaprub and WinPap source
(incorrectly) check for the WIN32 pre-processor macro as a proxy for
building on a Windows platform. The source should really be check the _WIN32 macro so one doesn’t need to define WIN32 and things just
work when building with MinGW, VC++ IDE, or Windows SDK.
That said, I’ve just downloaded the WinPcap dev pack from WinPcap · Developer Resources and will hopefully find time this
weekend to get the pcap and packetfu gems to work on my Win7 32bit
w/1.9.3 system.
C:\Users\Jon\Downloads\temp\pcaprub-0.11.2>gem install
pcaprub0.11.3.a1.gem – --with-pcap-dir=c:/devlibs/winpcap
Temporarily enhancing PATH to include DevKit…
Building native extensions. This could take a while…
Successfully installed pcaprub-0.11.3.a1
1 gem installed
AWESOME! By chance I noticed our fix was looking in
c:\devlib\wincap\include. However extracting the devpack puts it in
c:\devlib\wincap\wpdpack\
I moved everything in wpdpack up into wincap and the build process went
flawlessly. Running tests now…
C:\Ruby193\lib\ruby\gems\1.9.1\gems\pcaprub-0.11.2>gem install
pcaprub-0.11.3.a
.gem – --with-pcap-dir=c:/devlibs/winpcap/include
Temporarily enhancing PATH to include DevKit…
Building native extensions. This could take a while…
ERROR: Error installing pcaprub-0.11.3.a1.gem:
ERROR: Failed to build gem native extension.
C:/Ruby193/bin/ruby.exe extconf.rb
–with-pcap-dir=c:/devlibs/winpcap/i
clude
[*] Running checks for pcaprub code…
platform is i386-mingw32
checking for main() in -lws2_32… yes
checking for main() in -liphlpapi… yes
checking for windows.h… yes
checking for winsock2.h… yes
checking for iphlpapi.h… yes
checking for pcap_open_live() in -lwpcap… no
checking for pcap_setnonblock() in -lwpcap… no
creating Makefile
make
generating pcaprub-i386-mingw32.def
compiling pcaprub.c
pcaprub.c:8:18: fatal error: pcap.h: No such file or directory
compilation terminated.
make: *** [pcaprub.o] Error 1
Gem files will remain installed in
C:/Ruby193/lib/ruby/gems/1.9.1/gems/pcaprub-
.11.3.a1 for inspection.
Results logged to
C:/Ruby193/lib/ruby/gems/1.9.1/gems/pcaprub-0.11.3.a1/ext/pca
rub/gem_make.out
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.