首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何将NPCap库安装到Visual Studio中

如何将NPCap库安装到Visual Studio中
EN

Stack Overflow用户
提问于 2020-01-20 23:26:32
回答 1查看 450关注 0票数 1

我正在尝试将NPCap库安装到Visual Studio中,这样我就可以从文档中运行此代码。

代码语言:javascript
复制
#include "pcap.h"

main()
{
pcap_if_t* alldevs;
pcap_if_t* d;
int i = 0;
char errbuf[PCAP_ERRBUF_SIZE];

/* Retrieve the device list from the local machine */
if (pcap_findalldevs_ex(PCAP_SRC_IF_STRING, NULL /* auth is not needed */, &alldevs, errbuf) == -1)
{
    fprintf(stderr, "Error in pcap_findalldevs_ex: %s\n", errbuf);
    exit(1);
}

/* Print the list */
for (d = alldevs; d != NULL; d = d->next)
{
    printf("%d. %s", ++i, d->name);
    if (d->description)
        printf(" (%s)\n", d->description);
    else
        printf(" (No description available)\n");
}

if (i == 0)
{
    printf("\nNo interfaces found! Make sure Npcap is installed.\n");
    return;
}

/* We don't need any more the device list. Free it */
pcap_freealldevs(alldevs);

}当我运行这段代码时,我得到了许多错误,其中之一是"cannot open source file "pcap/pcap.h"。其他错误说明变量未定义。我相信我没有正确安装这个库。

我在桌面上的同一目录中有.lib文件和.h文件,如此屏幕截图所示。

我还将Visual Studio中的目录更改为适当的文件夹。

根据以下网址中的说明:How to add additional libraries to Visual Studio project?

EN

回答 1

Stack Overflow用户

发布于 2020-01-24 14:39:34

从错误中

“无法打开源文件"pcap/pcap.h”

看起来它需要一个目录结构。包含所有头文件的名为"pcap“的目录。

您是否确认已将此文件夹路径也添加到库目录中。链接以供参考。

  1. https://docs.microsoft.com/en-us/cpp/build/reference/vcpp-directories-property-page?view=vs-2019
  2. https://www.tutorialspoint.com/how-to-include-libraries-in-visual-studio-2012
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/59826342

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档