How to compile WinPcap with Visual Studio 2010?

The documentation for WinPcap was pretty poor. The last update for Visual Studio was for 2005, so this hasn’t been updated for Visual Studio 2008 or Visual Studio 2010.

Also, the steps don’t say what type of C++ project was created. This is probably why it missing information, such as the fact that WIN32 must be defined.

So I thought I would get it working and provide a post someone could actually find. I had to read the pcap.h file myself to figure out what was missing in the documentation.


It is expected you have Visual Studio 2010 already. It may work the same with Visual C++ 2010.

Step 1 – Create a new empty project

  1. In Visual Studio go to File | New | Project.
  2. Select Other Languages | Visual C++ | General | Empty Project
  3. Enter a Project name, Location, and Solution Name.
  4. Take note of the solution directory.
  5. Click OK.

This creates the following directory structure:


Step 2 – Create a main.cpp file

  1. Right-click on the project and choose Add | New Item.
  2. Select C++ File (.cpp)
  3. Enter the name as Main.cpp.
  4. Click Ok.
  5. Add the standard main function to the file:
    int main(int argc, char *argv[])
  6. Save the file.

Step 3 – Download and extract WinPCap

  1. Go to the WinPcap developer page:
  2. Download the latest stable version of WinPcap.
  3. Extract to your solution directory.

Step 4 – Configure the Project properties

Now that the needed resources are in your solution directory, you can configure your project to access them.

  1. In Visual Studio, right-click on your project and choose Properties.
  2. Make the following configuration changes to your project:

Configuration 1 – Add Additional Include Directories

  1. Go to Configuration Properties | C/C++ | General.
    Note: If you don’t see the C/C++ option, did you forget to do Step 2 above?
  2. For Additional Include Directories add the relative path:

Configuration 2 – Add Preprocessor Definitions

  1. Go to Configuration Properties | C/C++ | Preprocessor.
  2. For Preprocessor Definitions, add these three:

Preprocessor Definintions

Important: If you fail to add WIN32, your compile will fail as follows:

Error	1	error C1083: Cannot open include file: 'sys/time.h': No such file or directory	c:\users\jared\documents\visual studio 2010\projects\c++\readpcapexample\libs\winpcap-4.1.2\include\pcap\pcap.h	47	1	ReadPCapExample

Configuration 3 – Add Additional Library Directories

  1. Go to Configuration Properties | Linker | General.
  2. For Additional Library Directories enter the following:

Configuration 4 – Add Additional Dependencies

  1. Go to Configuration Properties | Linker | Input.
  2. For Additional Dependencies, add the following:

Additional Dependencies

Note: I removed the default libraries. You may need some of them:

Step 5 – Include pcap.h

  1. Open the Main.cpp file.
  2. Include pcap.h.
    int main(int argc, char *argv[])
  3. Try to compile and it should work.
You are now ready to develop using WinPcap.


  1. resources says:


    Rhyous » Blog Archive » How to compile WinPcap with Visual Studio 2010?

  2. スーパーコピー,スーパーコピー時計,ブランド偽物コピーN級品,日本最大級のブランド時計・バッグ・財布N級品専門店


  3. オメガ時計 京都 xバンドレーダー

    ERROR: The requested URL could not be retrieved

  4. professional teeth whitening in West Los Angeles

    How to compile WinPcap with Visual Studio 2010? | Rhyous

  5. Shrike says:

    I get the weirdest error.
    "The C++ Standard Library forbids macroizing keywords. Enable warning C4005 to find the forbidden macro."

  6. Hind says:

    thanks for This.

    do i have to do these steps for every time i want to open new project ?

  7. stefan says:

    I build it successfully but when I try to run it it says that wpcap.dll is missing. Using visual studio C++ 2012 and Winpcap 4.1.2 developers pack

  8. Ami Data Tech. says:

    Thanks for this!
    However I would like to know how can I use later my project on another computer ?
    it doesn't create any dll that I can transfer ?!

  9. bedoui says:

    i have the same error
    cannot open file 'winpcap.lib'

  10. Prabha says:

    Created a small project in VC ++ 6.0 . Included pcap.h in source file.

    in Build menu observed the error msg " Cannot compile pcap-stdinc.h : no

    compile tool is associated with this file extension. please let me where i

    missed any step.

  11. mimosa says:

    Very helpful. Thank you!

  12. Evan says:

    Thanks for this! Quick and easy to follow. Worked out great.

  13. Mreza says:

    I've got the following error:

    cannot open file 'winpcap.lib' c:\Users\Taesiri\documents\visual studio 2010\Projects\WinPcapExample\WinPcapExample\LINK WinPcapExample

    (LINK folder doesn't exist!) 🙁

    thanks for the article BTW!

  14. [...] How to compile WinPcap with Visual Studio 2010? [...]

Leave a Reply

How to post code in comments?