title: Winpcap Developer Usage with Cygwin C++ & Netbeans IDE
body: <p>Looking to get the Winpcap developer pack (4.1.2) running on Windows 7 64-bit.  I'm programming in C/C++ in the Netbeans IDE with the Cygwin (4.1.10) compiler.  I'd like to directly pull some GPS data from UDP packets instead of using another program where I go through an intermediate step and pull them from a text file.  If I can't sort this out I'm gonna try in Ubuntu next and see if I can get libpcap working there (even though Windows is preferred because of other equipment I am using).  Here's where I'm at (my main resources have been gathered from <a href="http://www.codeproject.com/Articles/30234/Introduction-to-the-WinPcap-Networking-Libraries" rel="nofollow">Introduction to the WinPcap Networking Libraries</a>, <a href="http://www.winpcap.org/docs/docs_412/html/group__wpcapsamps.html" rel="nofollow">Using WinPcap in your programs</a>, and Programming with pcap at tcpdump.org (note: I can't post the third link because it says my reputation needs to be higher)):</p>
  
  <ol>
  <li>I've installed the winpcap developers pack to C:\Users\\Documents</li>
  <li>I've installed the winpcap dll (though I'm not actually sure why this is necessary since all of the documentation I've seen only seems to use the .lib files)</li>
  <li>As instructed from the above links I've added the following settings in my project:
  <ul>
  <li>For the "Include Directories and Headers" I put the path to the winpcap <strong>Include</strong> folder from the developer pack</li>
  <li>For "Preprocessor Definitions" I've added <strong>HAVE_REMOTE</strong> and <strong>WPCAP</strong></li>
  <li>For "Additional Library Directories" I put the path to the winpcap <strong>Lib</strong> folder from the developer pack</li>
  </ul></li>
  </ol>
  
  <p>By doing all of the above and including the <strong>pcap.h</strong> header with no additional code I can compile my program.  However, the install instructions I've been referencing also state to add the following two "Additional Dependencies": <strong>winpcap.lib</strong> and <strong>Packet.lib</strong></p>
  
  <p>As soon as I do that I can't compile and get the following:</p>
  
  <pre><code>make[2]: Entering directory '/cygdrive/c/Users/&lt;user&gt;/Documents/NetBeansProjects/GPS_Parcer'
  make[2]: *** No rule to make target 'winpcap.lib', needed by 'dist/Debug/Cygwin_4.x-Windows/gps_parcer.exe'.  Stop.
  make[2]: Leaving directory '/cygdrive/c/Users/&lt;user&gt;/Documents/NetBeansProjects/GPS_Parcer'
  nbproject/Makefile-Debug.mk:61: recipe for target '.build-conf' failed
  make[1]: *** [.build-conf] Error 2
  make[1]: Leaving directory '/cygdrive/c/Users/&lt;user&gt;/Documents/NetBeansProjects/GPS_Parcer'
  nbproject/Makefile-impl.mk:39: recipe for target '.build-impl' failed
  make: *** [.build-impl] Error 2
  </code></pre>
  
  <p>Out of curiosity to see if those dependencies actually mattered I removed them and then added some basic code I copied from tcpdump.org:</p>
  
  <pre><code>#include &lt;stdio.h&gt;
  #include &lt;pcap.h&gt;
  
  int main(int argc, char *argv[])
  {
      char *dev, errbuf[PCAP_ERRBUF_SIZE];
  
      dev = pcap_lookupdev(errbuf);  //error is here!
  
      if (dev == NULL) {
          fprintf(stderr, "Couldn't find default device: %s\n", errbuf);
          return(2);
      }
      printf("Device: %s\n", dev);
      return(0);
  }
  </code></pre>
  
  <p>I get an <code>undefined reference to 'pcap_lookupdev'</code> error.</p>
  
  <p>I've also read that possibly Winpcap will only work with MS Visual Studio stuff so I actually don't know if that's true.</p>
  
  <p>Sorry for the long write-up, but if anybody has some insights or experience with this it would be much appreciated.</p>