0

I am trying to use the pcap++ library. I have downloaded the libraries for the VS2017, I linked the libraries and also the header files.

The libraries are:

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

and I made sure I am using the right release library.

When I build the solution, I am getting the error: LNK2019 unresolved external symbol _pcap_setfilter referenced in function "public: virtual bool __thiscall pcpp::IPcapDevice::setFilter

The code is simple:

#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;
}

Does anyone have any idea on how to resolve this?

  • 1
    I imagine you need to link to the pcap library – Alan Birtles Nov 23 '21 at 08:30
  • @AlanBirtles I did that already. Unfortunately It did not work – Ahmed Yousif Nov 23 '21 at 08:43
  • I'm not sure if you downloaded the library files from the release page: https://github.com/seladb/PcapPlusPlus/releases/download/v21.11/pcapplusplus-21.11-windows-vs2017.zip, if you do you will find a `README.release` file inside with detailed instructions on how to build your code and also an example VS project/solution you can use – seladb Nov 23 '21 at 08:46
  • @AhmedYousif you are linking to the pcap++ library, but not to the underlying pcap library that it wraps. You need to link to both – Remy Lebeau Nov 23 '21 at 20:19

0 Answers0