我正在编写一个使用Winpcap
.I 的网络工具。我正在使用 Visual Studio 2017 。
Winpcap
是一个外部库,我必须在我的程序中包含pcap.h
. 我当然知道这些:
(1) 编译器需要知道头文件的位置。
(2) 链接器需要知道.lib文件所在的位置,以及lib文件名
现在我有一个像这样的通信器类
#include<pcap.h>
#pragma once
class Communicator
{
public:
pcap_if_t *alldevs;
pcap_t *fp;
int findAllDevice(void);
//int openAdapter(char* _name);
//void readNexLoop(void);
//void startCommunicator(void);
Communicator();
~Communicator();
};
.cpp 文件:
#include "stdafx.h"
#include "Communicator.h"
//#include<thread>
Communicator::Communicator()
{
}
Communicator::~Communicator()
{
}
int Communicator::findAllDevice()
{
int result = -1;
char errbuf[PCAP_ERRBUF_SIZE + 1];
result = pcap_findalldevs(&alldevs, errbuf);
//result = pcap_findalldevs(&alldevs, errbuf);
//pcap_freealldevs(alldevs);
return result;
}
但是当我构建它时,有错误
Error LNK2019 unresolved external symbol _pcap_findalldevs referenced in function "public: int
__thiscall Communicator::findAllDevice(void)" (?findAllDevice@Communicator@@QAEHXZ)
MobinServer2.0 D:\MobinServer2.0\MobinServer2.0\Communicator.obj 1
任何人都可以对此有所了解,我做错了什么?我需要帮助这个请帮我解决。谢谢