如何在代码块中链接winpcap? [英] How can I link winpcap in Code Blocks?

查看:218
本文介绍了如何在代码块中链接winpcap?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道链接Wincap库并在代码块中开发的c ++项目中使用它的过程。

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

推荐答案

在自己努力完成这项工作之后,我想应该将解决方案发布在这里。

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

您将需要下载WinPCap的开发人员版本并将其解压缩,例如 C:\WpdPack_4_1_2。

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

Code :: Blocks 中,您需要添加包含子目录到搜索目录。为此,请转到设置->编译器并单击搜索目录选项卡。对于编译器,链接器和资源编译器选项卡,您需要添加搜索路径。以上面的位置为例,它将是 C:\WpdPack_4_1_2\WpdPack\Include

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.

然后,您需要将库文件添加到您的项目构建设置中。为此,右键单击左侧的粗体项目名称,然后选择构建选项。在链接器设置选项卡下,将路径添加到 libwpcap.a文件。

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.

例如,将是 C:\WpdPack_4_1_2\WpdPack\Lib\libwpcap.a

完成此操作后,示例程序可以正常编译。确保在程序中添加 #include pcap.h 以使用该库。

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

这篇关于如何在代码块中链接winpcap?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆