使用 PCAP++ 时的LINK2019

问题描述 投票:0回答:1

我正在尝试使用 pcap++ 库。我已经下载了 VS2017 的库,我链接了库和头文件。

图书馆是:

Common++.lib
Packet++.lib
Pcap++.lib

并且我确保我使用的是正确的发布库。

当我构建解决方案时,出现错误:LNK2019 无法解析的外部符号 _pcap_setfilter 在函数“public: virtual bool __thiscall pcpp::IPcapDevice::setFilter 中引用”

代码很简单:

#include "pch.h"
#include "IPv4Layer.h"
#include "Packet.h"
#include "PcapFileDevice.h"

int main(int argc, char* argv[])
{
    // open a pcap file for reading
    pcpp::PcapFileReaderDevice reader("1_packet.pcap");
    if (!reader.open())
    {
        printf("Error opening the pcap file\n");
        return 1;
    }

    reader.close();

    return 0;
}

有人知道如何解决这个问题吗?

c++ pcap pcapplusplus
1个回答
0
投票

我通过添加解决它:

#pragma comment(lib, "ws2_32.lib")
© www.soinside.com 2019 - 2024. All rights reserved.