当前位置:网站首页>【QT】无法在QT创建者中打开包含文件pcap.h(C1083)
【QT】无法在QT创建者中打开包含文件pcap.h(C1083)
2022-07-27 06:04:00 【Cappuccino-jay】
问题描述:
当我尝试将winpcap链接到我的QT创建者项目中
然后引入#include <pcap.h>时,代码助手会自动填充
但在编译时却得到:
Error:C1083: Cannot open include file: 'pcap.h': No such file or directory
解决方法:
在 C 盘下新建一个 WpdPack文件夹,然后将 Include 和 Lib 两个文件夹拷贝到该文件夹中。
在项目文件 .pro 添加以下内容:
INCLUDEPATH += C:/WpdPack/Include
LIBS += C:/WpdPack/Lib/wpcap.lib
LIBS += C:/WpdPack/Lib/Packet.lib
CONFIG += no_lflags_merge
说明:这里文件夹的位置可自由选定,只要项目文件中的文件路径保持一致即可
工具包下载
1、 WinPcap 程序,解压后安装。
2、 WpdPack 工具包,解压后文件夹下包含有 Include 和 Lib 两个子文件夹。
测试代码:
#include <QCoreApplication>
#include <QDebug>
#define HAVE_REMOTE
#include <pcap.h>
#include <remote-ext.h>
int main(int argc, char *argv[])
{
QCoreApplication a(argc, argv);
pcap_if_t *alldevs;
char errbuf[PCAP_ERRBUF_SIZE];
/* Retrieve the device list from the local machine */
if (pcap_findalldevs_ex(PCAP_SRC_IF_STRING, NULL /* auth is not needed */,
&alldevs, errbuf) == -1) {
fprintf(stderr,"Error in pcap_findalldevs_ex: %s\\n", errbuf);
exit(1);
}
/* Print the list */
pcap_if_t *d;
int i=0;
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");
} else {
/* We don‘t need any more the device list. Free it */
pcap_freealldevs(alldevs);
}
return a.exec();
}
边栏推荐
- 基于SSM图书借阅管理系统
- Watermelon book learning notes - Chapter 1 and 2
- PNA modified polypeptide arms PNA PNA DNA suc aapf PNA suc - (ALA) 3 PNA
- Interpretation of deepsort source code (VII)
- R2LIVE代码学习记录(3):对雷达特征提取
- The qualities that a technical manager should have (guess)
- Pytorch notes: td3
- A Competitive Swarm Optimizer for Large Scale Optimization
- Interpretation of deepsort source code (I)
- ?实验 7 基于 Mysql 的 PHP 管理系统实现
猜你喜欢

Web configuration software for industrial control is more efficient than configuration software

把Excel转换成CSV/CSV UTF-8

Gbase 8C product introduction

C4D云渲染平台选哪家合作?

Analysis of strong tennis cup 2021 PWN competition -- babypwn

Drools (5): drools advanced syntax

Student achievement management system based on SSM

Leetcode series (I): buying and selling stocks

The vscode run command reported an error: the mark "&" is not a valid statement separator in this version.

Basic statement of MySQL (1) - add, delete, modify and query
随机推荐
Automatically generate UML sequence diagram according to text (draw.io format)
The possibility of metauniverse from the perspective of technical principles: how Omniverse "built" Mars
Digital image processing - Chapter 6 color image processing
Student status management system based on SSM
Misunderstanding of slice slice in golang
Watermelon book learning Chapter 5 --- neural network
Jest single test style problem [identity obj proxy] NPM package
Vscode connection remote server development
Codeforces Round #787 (Div. 3)(7/7)
DNA coupled PbSe quantum dots | near infrared lead selenide PbSe quantum dots modified DNA | PbSe DNA QDs
网易云信亮相 GIAC 全球互联网架构大会,解密新一代音视频架构在元宇宙场景的实践...
VScode连接远程服务器开发
12. Integer to Roman整数转罗马数字
Codeforces Round #809 (Div. 2)(6/6)(Kruskal重构树)
二叉树--天然的查找语义(1)基础篇
Pytorch model
Codeforces Round #787 (Div. 3)(7/7)
Gbase 8C - SQL reference 6 SQL syntax (13)
Netease Yunxin appeared at the giac global Internet architecture conference to decrypt the practice of the new generation of audio and video architecture in the meta universe scene
Codeforces Round #804 (Div. 2)(5/5)