seladb / PcapPlusPlus

PcapPlusPlus is a multiplatform C++ library for capturing, parsing and crafting of network packets. It is designed to be efficient, powerful and easy to use. It provides C++ wrappers for the most popular packet processing engines such as libpcap, Npcap, WinPcap, DPDK, AF_XDP and PF_RING.
https://pcapplusplus.github.io/
The Unlicense
2.68k stars 652 forks source link

linker error #88

Closed xxhenglyxx closed 6 years ago

xxhenglyxx commented 6 years ago

Platform: Macosx - High Sierra

First time using this library, I cloned the repository and successfully built it. I am trying to test if it works by copying and running the reading pcap example from the documentation. Here is how i compile and build it

g++ -Iinclude -c main.cpp --std=c++14
g++ main.o lib/libCommon++.a lib/libPacket++.a lib/libPcap++.a

And I used the pcaps that was being captured by using wireshark and export it as .pcap file, changed the file name and run it, and this is the output i got:

screen shot 2018-02-07 at 11 39 40 pm

echo-Mike commented 6 years ago

@xxhenglyxx You need to install libpcap to your PC. Please refer to this guide(MacOS section): http://seladb.github.io/PcapPlusPlus-Doc/download.html

xxhenglyxx commented 6 years ago

@echo-Mike I already have libpcap installed from brew before installing PcapPlusPlus, and I did followed the instruction from the page you refer me to, but still did not work.

seladb commented 6 years ago

Hi @xxhenglyxx thanks for using PcapPlusPlus. Regarding your problem:

seladb commented 6 years ago

@xxhenglyxx did you have a chance to go over the items mentioned above?

xxhenglyxx commented 6 years ago

@seladb sorry for the late replies. I compiled it successfully but I did not compiled the example provided with the library. I already install the Xcode command line tools, removing --std=c++14 did not help also.

xxhenglyxx commented 6 years ago

I went to look at the Tests folder and ran the Packet++Test, the result was only 3 pass and the rest got failed, why is like that ? The 3 that was passed is EthPacketCreation, Ipv4PacketCreation, InsertDataToPacket. And this is the Pcap++Test screen shot 2018-02-10 at 3 11 39 pm

seladb commented 6 years ago

@xxhenglyxx you should run it from Packet++Test folder, meaning:

cd /<your_pcapplusplus_folder>/Tests/Packet++Test
Bin/Packet++Test

Same for Pcap++Test:

cd /<your_pcapplusplus_folder>/Tests/Pcap++Test
sudo Bin/Pcap++Test -i <interface_ip>
xxhenglyxx commented 6 years ago

@seladb Yes I did run exactly like that. After I cloned the library, I cd into my Downloads/PcapPlusPlus/... and run the test from within. I feel like I miss something so that is why it wont work, is there anything I should have beside the thing inside the documentation ?

seladb commented 6 years ago

have you run the configure-mac_os_x.sh script?

I'd advise you to start fresh - clone the library again, run the configuration script, run the make command and then try to run the unit-tests. It'd be great if you can attach the console output to this ticket

seladb commented 6 years ago

Hi, any updates on this issue?

xxhenglyxx commented 6 years ago

@seladb Yes so sorry for the late reply. I did run the configure-mac_os_x.sh script and the script ran successfully. I will clone the library again and redo everything all over then will update on this issue again.

xxhenglyxx commented 6 years ago

So I cloned the library again, and ran configure-mac_os_x.sh, then follow up with ./configure-linux.sh --use-immediate-mode. then running make all this time throws me these errors: screen shot 2018-02-19 at 9 35 09 pm

seladb commented 6 years ago

@xxhenglyxx you shouldn't run configure-linux.sh --use-immediate-mode since you're on a Mac. You should run only configure-mac_os_x.sh. If you want to use immediate mode you can run: configure-mac_os_x.sh --use-immediate-mode instead. Please let me know if it solves these errors

xxhenglyxx commented 6 years ago

It successfully build but here are the test results: screen shot 2018-02-21 at 11 05 38 pm screen shot 2018-02-21 at 11 05 28 pm screen shot 2018-02-21 at 11 05 17 pm

seladb commented 6 years ago

You should run the unit-test from its own directory:

cd <pcapplusplus_home>/Tests/Packet++Test
Bin/Packet++Test

cd <pcapplusplus_home>/Tests/Pcap++Test
sudo Bin/Pcap++Test -i <your_ip_address>
xxhenglyxx commented 6 years ago

Yes I did run it from its own unit-test directory. After I cloned it at some location, then cd into it, follow all the installation steps, then run unit test within it.

seladb commented 6 years ago

The unit-test applications fail to read the input files for some reason, with the info I have it's hard for me to say why. One more thing I can suggest is to record everything you do and send me the output as a text file, not as an image. Please record everything from cloning the project to running the unit-tests

xxhenglyxx commented 6 years ago

Ok I will do that and send it to you.

xxhenglyxx commented 6 years ago

Here is the file: output.txt

seladb commented 6 years ago

Thanks!

I've identified the problem:

You're running:

cd Tests/Packet++Test/Bin
./Packet++Test

But you should run:

cd Tests/Packet++Test
Bin/Packet++Test

Same for Pcap++Test, you're running:

cd Tests/Pcap++Test/Bin
./Pcap++Test

but you should run:

cd Tests/Pcap++Test
sudo Bin/Pcap++Test -i <your_ip_address>

Please let me know if it solves the problem

xxhenglyxx commented 6 years ago

@seladb Wow. Yes everything are passed now.

seladb commented 6 years ago

Awesome! If that's ok with you, I'll close the issue now. Please reopen it if you still encounter issues