Recently Learning Network programming, want to use QT in Windows to do a network capture tool, it is necessary to use WINPCAP, and my Computer system is Win7 64-bit, QT version is QT 5.3.1 for Windows 64-bit (VS, OpenGL), QT and WinPcap are therefore configured under the WIN7 64-bit system.
1, to http://www.winpcap.org/install/default.htm download the latest WinPcap installation package, and install, run the WinPcap-based program needs its support.
2. To http://www.winpcap.org/devel.htm download the development package, copy all the contents of the Include directory in the WinPcap development package to the QT msvc2013_64_opengl/include directory.
3. Copy the Packet.lib and Wpcap.lib under the x64 directory in the Lib directory in the WinPcap development package to the Msvc2013_64_opengl/lib directory.
Complete the three steps above and you can.
Here is an example of a test.
Create a new empty QT project and add main.cpp.
#include <stdio.h>
#include <stdlib.h>
#define Have_remote
#include <pcap.h>
int main ()
{
pcap_if_t *alldevs;
pcap_if_t *d;
int i = 0;
Char Errbuf[pcap_errbuf_size];
/* Get local devices */
if (PCAP_FINDALLDEVS_EX (pcap_src_if_string, NULL, &alldevs, errbuf) = =-1)
{
fprintf (stderr, "Error in PCAP_FINDALLDEVS_EX:%s\n", errbuf);
Exit (1);
}
/* Print Devices list */
for (d = alldevs; d = NULL; d = d->next)
{
printf ("%d.%s", ++i, D->name);
if (d->description)
printf ("(%s)- =---- \ n", d->description);
Else
printf ("(No description available) \ n");
}
if (i = = 0)
{
printf ("\nno Interfaces found! Make sure Winpcap is installed.\n ");
return-1;
}
Pcap_freealldevs (Alldevs);
return 0;
}
SOURCE Link: http://download.csdn.net/detail/qq_17242957/9469072
http://blog.csdn.net/qq_17242957/article/details/50953630
http://blog.csdn.net/qq_17242957/article/details/50979646
WinPcap configuration under VS2012 Qt5 X64