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. professional teeth whitening in West Los Angeles

    How to compile WinPcap with Visual Studio 2010? | Rhyous

  2. プラダ スーパーコピー,プラダ 財布 コピー,プラダ 新作 財布ブランド財布コピー,ブランド スーパーコピー 財布,プラダ スーパーコピー 財布,シャネル財布コピー,グッチ スーパーコピー 財布,エルメス スーパーコピー 財布,ルイヴィトン長財布コピー,スーパーコピー財布,エルメスコピー財布,各種のブランドはかばんをコピーします偽物ブランド,激安偽物,ブランド財布コピー,エルメス財布コピー,ブランドのコピーブランド財布,ルイ?ヴィトンブランド財布コピー,偽ブランドグッチ財布,D&G,コピー財布偽物,偽物時計コピー,時計,ボッテガベルト,,靴,その他のバッグコピー,ブランド財布激安,ブランド激安販売,偽ブランド激安市場,通販送料無料專門店 ルイヴィトンコピー 児玉店,当店ルイヴィトン コピー 財布、ルイヴィトン コピー バッグ 全MAX80%OFF!期間限定SALE。最短即日発送。送料無料ルイヴィトン コピー,ルイヴィトン コピー 財布,ルイヴィトン コピー バッグ

  3. スーパーコピーブランド格安販売店はこちらへ!品々の激安価格に持ったスーパーコピーブランド 代引きの新作はお客様に提供されます。安心、迅速、確実、お客様の手元にお届け致します。★弊社は9年の豊富な経験と実績を持っております。★一流の素材を選択し、精巧な作り方でまるで本物のようなな製品を造ります。★品質を重視、納期も厳守、お客様第一主義を貫きは当社の方針です。★驚きの低価格で商品をお客様に提供致します!★早速に購入へようこそ!

  4. Shrike says:

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

  5. Hind says:

    thanks for This.

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

  6. 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

  7. 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 ?!

  8. bedoui says:

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

  9. 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.

  10. mimosa says:

    Very helpful. Thank you!

  11. Evan says:

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

  12. 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!

Leave a Reply

How to post code in comments?