Problem 1:
On the MSYS Bash Shell,
$ gcc -o testprog testprog.c -lpcap
c:/omnetpp-4.1-rc2-src-windows/mingw/bin/../lib/gcc/mingw32/4.5.0/../../../../mingw32/bin/ld.exe: cannot find -lpcap
Solution. Change from -lpcap to -lwpcap:
$ gcc -o testprog testprog.c -lwpcap
This is because
C:\omnetpp-4.1-rc2-src-windows\mingw\lib\wpcap.lib and
C:\omnetpp-4.1-rc2-src-windows\mingw\lib\libwpcap.a.
Problem 2:
$ gcc -o testprog testprog.c -lwpcap
testprog.c: In function 'main':
testprog.c:12:29: error: 'PCAP_SRC_IF_STRING' undeclared (first use in this function)
Solution:
Change from
//if (pcap_findalldevs_ex(PCAP_SRC_IF_STRING, NULL /* auth is not needed */, &alldevs, errbuf) == -1)
to
if (pcap_findalldevs_ex("127.0.0.1", NULL, &alldevs, errbuf) == -1)
{
...
}
The 127.0.0.1 is the localhost IP number.
Run it. On my Windows 7 workstation, the obtained result is:
$ testprog
1. rpcap://\Device\NPF_{88888888-4444-4444-4444-48D0E52A0B83} (Network adapter 'Atheros(NDIS6.20)' on local host)
2. rpcap://\Device\NPF_{88888888-4444-4444-4444-8B5EC6C7F430} (Network adapter 'Sun' on local host)
Reading. Practice. Writing.
Please feel free to comment. Suggestions are also welcomed here. Write something "wholesome serving purpose" here.
Subscribe to:
Post Comments (Atom)
Newton-Raphson Method in C++
The Newton Raphson Method is an open method used to find the roots of a function. It employs the technique of linear approximation and invol...
-
Open LibreOffice Draw program. Select the rectangle shape from shape toolbar at the bottom of drawing page. Click a point and drag-and-re...
-
DiGi Super Long Life is a feature where you can extend your talktime validity to 1 year for just RM38. Indirectly, the subscription fee is ...
-
DiGi Super Long Life is a feature where you can extend your talktime validity to 1 year for just RM30. Indirectly, the subscription fee is...
No comments:
Post a Comment