How can I link winpcap in Code Blocks?

2019-07-14 13:47发布

Id like to know the process to link the Wincap library and use it in my c++ project im developing in Code Blocks.

1条回答
我命由我不由天
2楼-- · 2019-07-14 14:36

After struggling to do this myself I figured that I should post my solution here.

You will need to download the developer version of WinPCap and unzip it somewhere, lets say "C:\WpdPack_4_1_2".

In Code::Blocks, you need to add the "Include" sub directory to the search directories. To do this, go to settings->compiler and click on the "Search directories" tab. For the "Compiler" "Linker" and "Resource compiler" tabs you need to add the search path. Using the location above as an example, it would be C:\WpdPack_4_1_2\WpdPack\Include.

Once these have been added, click "OK" to return to the main screen.

Then, you need to add the library file to your project build settings. To do this, right click on your bolded project name on the left side and choose "Build options". Under the "Linker settings" tab add the path to the "libwpcap.a" file.

For example, it would be C:\WpdPack_4_1_2\WpdPack\Lib\libwpcap.a.

After I did this, the example programs compiled fine. Make sure to add the #include "pcap.h" in your program to use the library.

查看更多
登录 后发表回答