1

I wish to learn the PcapPlusPlus library in order to manipulate packets. I am using a Cygwin terminal on Windows 10 with all the development tools installed in Cygwin. So, i downloaded the pcapplusplus-20.08-windows-mingw-w64-gcc-8.1.0.zip package of PcapPlusPlus from Github. Then i extracted it and went to the example-app folder. Tried building the app. To do so, I ran the following command:

g++.exe -I C:\Users\home-pc\Desktop\projects\pcapplusplus\header\ -I C:\cygwin64\home\home-pc\WpdPack\Include\ C:\Users\home-pc\Desktop\projects\pcapplusplus\example-app\main.cpp -o C:\Users\home-pc\Desktop\projects\pcapplusplus\example-app\main.exe

Here,

  • C:\Users\home-pc\Desktop\projects\pcapplusplus\header\ folder contains header files of PcapPlusPlus
  • C:\cygwin64\home\home-pc\WpdPack\Include\ folder contains include header files of WinPcap needed for this tool to work.

When i run this command i get lots of errors. I am new to using C++ libraries. What am i doing wrong here and how to fix it? My errors are as follows:

/usr/lib/gcc/x86_64-pc-cygwin/10/../../../../x86_64-pc-cygwin/bin/ld: /cygdrive/c/Users/home-pc/AppData/Local/Temp/ccW3DOf2.o:C:\Users\home-pc\Desktop\projects\pcapplusplus\example-app\main.cpp:(.text+0x3e): undefined reference to pcpp::PcapFileReaderDevice::open()' /cygdrive/c/Users/home-pc/AppData/Local/Temp/ccW3DOf2.o:C:\Users\home-pc\Desktop\projects\pcapplusplus\example-app\main.cpp:(.text+0x3e): relocation truncated to fit: R_X86_64_PC32 against undefined symbol pcpp::PcapFileReaderDevice::open()' /usr/lib/gcc/x86_64-pc-cygwin/10/../../../../x86_64-pc-cygwin/bin/ld: /cygdrive/c/Users/home-pc/AppData/Local/Temp/ccW3DOf2.o:C:\Users\home-pc\Desktop\projects\pcapplusplus\example-app\main.cpp:(.text+0x66): undefined reference to pcpp::RawPacket::RawPacket()' /cygdrive/c/Users/home-pc/AppData/Local/Temp/ccW3DOf2.o:C:\Users\home-pc\Desktop\projects\pcapplusplus\example-app\main.cpp:(.text+0x66): relocation truncated to fit: R_X86_64_PC32 against undefined symbol pcpp::RawPacket::RawPacket()' /usr/lib/gcc/x86_64-pc-cygwin/10/../../../../x86_64-pc-cygwin/bin/ld: /cygdrive/c/Users/home-pc/AppData/Local/Temp/ccW3DOf2.o:C:\Users\home-pc\Desktop\projects\pcapplusplus\example-app\main.cpp:(.text+0x75): undefined reference to pcpp::PcapFileReaderDevice::getNextPacket(pcpp::RawPacket&)' /cygdrive/c/Users/home-pc/AppData/Local/Temp/ccW3DOf2.o:C:\Users\home-pc\Desktop\projects\pcapplusplus\example-app\main.cpp:(.text+0x75): relocation truncated to fit: R_X86_64_PC32 against undefined symbol pcpp::PcapFileReaderDevice::getNextPacket(pcpp::RawPacket&)' /usr/lib/gcc/x86_64-pc-cygwin/10/../../../../x86_64-pc-cygwin/bin/ld: /cygdrive/c/Users/home-pc/AppData/Local/Temp/ccW3DOf2.o:C:\Users\home-pc\Desktop\projects\pcapplusplus\example-app\main.cpp:(.text+0xb5): undefined reference to pcpp::Packet::Packet(pcpp::RawPacket*, bool, unsigned long, pcpp::OsiModelLayer)' /cygdrive/c/Users/home-pc/AppData/Local/Temp/ccW3DOf2.o:C:\Users\home-pc\Desktop\projects\pcapplusplus\example-app\main.cpp:(.text+0xb5): relocation truncated to fit: R_X86_64_PC32 against undefined symbol pcpp::Packet::Packet(pcpp::RawPacket*, bool, unsigned long, pcpp::OsiModelLayer)' /usr/lib/gcc/x86_64-pc-cygwin/10/../../../../x86_64-pc-cygwin/bin/ld: /cygdrive/c/Users/home-pc/AppData/Local/Temp/ccW3DOf2.o:C:\Users\home-pc\Desktop\projects\pcapplusplus\example-app\main.cpp:(.text+0x116): undefined reference to pcpp::IPv4Address::toString() const' /cygdrive/c/Users/home-pc/AppData/Local/Temp/ccW3DOf2.o:C:\Users\home-pc\Desktop\projects\pcapplusplus\example-app\main.cpp:(.text+0x116): relocation truncated to fit: R_X86_64_PC32 against undefined symbol pcpp::IPv4Address::toString() const' /usr/lib/gcc/x86_64-pc-cygwin/10/../../../../x86_64-pc-cygwin/bin/ld: /cygdrive/c/Users/home-pc/AppData/Local/Temp/ccW3DOf2.o:C:\Users\home-pc\Desktop\projects\pcapplusplus\example-app\main.cpp:(.text+0x135): undefined reference to pcpp::IPv4Address::toString() const' /cygdrive/c/Users/home-pc/AppData/Local/Temp/ccW3DOf2.o:C:\Users\home-pc\Desktop\projects\pcapplusplus\example-app\main.cpp:(.text+0x135): relocation truncated to fit: R_X86_64_PC32 against undefined symbol pcpp::IPv4Address::toString() const' /usr/lib/gcc/x86_64-pc-cygwin/10/../../../../x86_64-pc-cygwin/bin/ld: /cygdrive/c/Users/home-pc/AppData/Local/Temp/ccW3DOf2.o:C:\Users\home-pc\Desktop\projects\pcapplusplus\example-app\main.cpp:(.text+0x177): undefined reference to pcpp::IFileDevice::close()' /cygdrive/c/Users/home-pc/AppData/Local/Temp/ccW3DOf2.o:C:\Users\home-pc\Desktop\projects\pcapplusplus\example-app\main.cpp:(.text+0x177): relocation truncated to fit: R_X86_64_PC32 against undefined symbol pcpp::IFileDevice::close()' /usr/lib/gcc/x86_64-pc-cygwin/10/../../../../x86_64-pc-cygwin/bin/ld: /cygdrive/c/Users/home-pc/AppData/Local/Temp/ccW3DOf2.o:C:\Users\home-pc\Desktop\projects\pcapplusplus\example-app\main.cpp:(.text+0x193): undefined reference to pcpp::RawPacket::~RawPacket()' /cygdrive/c/Users/home-pc/AppData/Local/Temp/ccW3DOf2.o:C:\Users\home-pc\Desktop\projects\pcapplusplus\example-app\main.cpp:(.text+0x193): relocation truncated to fit: R_X86_64_PC32 against undefined symbol pcpp::RawPacket::~RawPacket()' /usr/lib/gcc/x86_64-pc-cygwin/10/../../../../x86_64-pc-cygwin/bin/ld: /cygdrive/c/Users/home-pc/AppData/Local/Temp/ccW3DOf2.o:C:\Users\home-pc\Desktop\projects\pcapplusplus\example-app\main.cpp:(.text+0x1e4): undefined reference to pcpp::RawPacket::~RawPacket()' /cygdrive/c/Users/home-pc/AppData/Local/Temp/ccW3DOf2.o:C:\Users\home-pc\Desktop\projects\pcapplusplus\example-app\main.cpp:(.text+0x1e4): relocation truncated to fit: R_X86_64_PC32 against undefined symbol pcpp::RawPacket::~RawPacket()' /usr/lib/gcc/x86_64-pc-cygwin/10/../../../../x86_64-pc-cygwin/bin/ld: /cygdrive/c/Users/home-pc/AppData/Local/Temp/ccW3DOf2.o:C:\Users\home-pc\Desktop\projects\pcapplusplus\example-app\main.cpp:(.text$_ZN4pcpp6PacketD1Ev[_ZN4pcpp6PacketD1Ev]+0x1f): undefined reference to pcpp::Packet::destructPacketData()' /cygdrive/c/Users/home-pc/AppData/Local/Temp/ccW3DOf2.o:C:\Users\home-pc\Desktop\projects\pcapplusplus\example-app\main.cpp:(.text$_ZN4pcpp6PacketD1Ev[_ZN4pcpp6PacketD1Ev]+0x1f): relocation truncated to fit: R_X86_64_PC32 against undefined symbol pcpp::Packet::destructPacketData()' /usr/lib/gcc/x86_64-pc-cygwin/10/../../../../x86_64-pc-cygwin/bin/ld: /cygdrive/c/Users/home-pc/AppData/Local/Temp/ccW3DOf2.o:C:\Users\home-pc\Desktop\projects\pcapplusplus\example-app\main.cpp:(.text$_ZN4pcpp17IFileReaderDeviceD2Ev[_ZN4pcpp17IFileReaderDeviceD2Ev]+0x31): undefined reference to pcpp::IFileDevice::~IFileDevice()' /cygdrive/c/Users/home-pc/AppData/Local/Temp/ccW3DOf2.o:C:\Users\home-pc\Desktop\projects\pcapplusplus\example-app\main.cpp:(.text$_ZN4pcpp17IFileReaderDeviceD2Ev[_ZN4pcpp17IFileReaderDeviceD2Ev]+0x31): additional relocation overflows omitted from the output /usr/lib/gcc/x86_64-pc-cygwin/10/../../../../x86_64-pc-cygwin/bin/ld: /cygdrive/c/Users/home-pc/AppData/Local/Temp/ccW3DOf2.o:C:\Users\home-pc\Desktop\projects\pcapplusplus\example-app\main.cpp:(.text$_ZN4pcpp20PcapFileReaderDeviceC1EPKc[_ZN4pcpp20PcapFileReaderDeviceC1EPKc]+0x1c): undefined reference to pcpp::IFileReaderDevice::IFileReaderDevice(char const*)' /usr/lib/gcc/x86_64-pc-cygwin/10/../../../../x86_64-pc-cygwin/bin/ld: /cygdrive/c/Users/home-pc/AppData/Local/Temp/ccW3DOf2.o:C:\Users\home-pc\Desktop\projects\pcapplusplus\example-app\main.cpp:(.rdata$_ZTVN4pcpp17IFileReaderDeviceE[_ZTVN4pcpp17IFileReaderDeviceE]+0x28): undefined reference to pcpp::IFileDevice::close()' /usr/lib/gcc/x86_64-pc-cygwin/10/../../../../x86_64-pc-cygwin/bin/ld: /cygdrive/c/Users/home-pc/AppData/Local/Temp/ccW3DOf2.o:C:\Users\home-pc\Desktop\projects\pcapplusplus\example-app\main.cpp:(.rdata$_ZTVN4pcpp17IFileReaderDeviceE[_ZTVN4pcpp17IFileReaderDeviceE]+0x38): undefined reference to pcpp::IPcapDevice::setFilter(std::string)' /usr/lib/gcc/x86_64-pc-cygwin/10/../../../../x86_64-pc-cygwin/bin/ld: /cygdrive/c/Users/home-pc/AppData/Local/Temp/ccW3DOf2.o:C:\Users\home-pc\Desktop\projects\pcapplusplus\example-app\main.cpp:(.rdata$_ZTVN4pcpp17IFileReaderDeviceE[_ZTVN4pcpp17IFileReaderDeviceE]+0x40): undefined reference to pcpp::IPcapDevice::clearFilter()' /usr/lib/gcc/x86_64-pc-cygwin/10/../../../../x86_64-pc-cygwin/bin/ld: /cygdrive/c/Users/home-pc/AppData/Local/Temp/ccW3DOf2.o:C:\Users\home-pc\Desktop\projects\pcapplusplus\example-app\main.cpp:(.rdata$_ZTVN4pcpp17IFileReaderDeviceE[_ZTVN4pcpp17IFileReaderDeviceE]+0x78): undefined reference to non-virtual thunk to pcpp::IPcapDevice::setFilter(std::string)' /usr/lib/gcc/x86_64-pc-cygwin/10/../../../../x86_64-pc-cygwin/bin/ld: /cygdrive/c/Users/home-pc/AppData/Local/Temp/ccW3DOf2.o:C:\Users\home-pc\Desktop\projects\pcapplusplus\example-app\main.cpp:(.rdata$_ZTVN4pcpp17IFileReaderDeviceE[_ZTVN4pcpp17IFileReaderDeviceE]+0x80): undefined reference to non-virtual thunk to pcpp::IPcapDevice::clearFilter()' /usr/lib/gcc/x86_64-pc-cygwin/10/../../../../x86_64-pc-cygwin/bin/ld: /cygdrive/c/Users/home-pc/AppData/Local/Temp/ccW3DOf2.o:C:\Users\home-pc\Desktop\projects\pcapplusplus\example-app\main.cpp:(.rdata$.refptr._ZTVN4pcpp20PcapFileReaderDeviceE[.refptr._ZTVN4pcpp20PcapFileReaderDeviceE]+0x0): undefined reference to vtable for pcpp::PcapFileReaderDevice' collect2: error: ld returned 1 exit status

Build finished with error(s). The terminal process terminated with exit code: -1.

Ðаn
  • 10,934
  • 11
  • 59
  • 95
capolir843
  • 53
  • 4
  • Remove spaces between `-I` and include folders: `g++.exe -IC:\Users\home-pc\Desktop\projects\pcapplusplus\header\ -IC:\cygwin64\home\home-pc\WpdPack\Include\ C:\Users\home-pc\Desktop\projects\pcapplusplus\example-app\main.cpp -o C:\Users\home-pc\Desktop\projects\pcapplusplus\example-app\main.exe` – nevilad Mar 09 '21 at 11:02
  • did that still now working – capolir843 Mar 09 '21 at 11:57
  • You need to specify PcapPlusPlus lib location, WinPcap lib location, as well as the lib names. Please follow the instruction in `README.release` in `pcapplusplus-20.08-windows-mingw-w64-gcc-8.1.0.zip` or take a look at `mk\PcapPlusPlus.mk` – seladb Mar 20 '21 at 09:14

0 Answers0