1
我正在与其他人专业制作的项目合作,所以代码应该没有错误。我遇到的问题很可能与项目配置有关。WinPCap设置给出“无法解析的外部符号”链接器错误
我正在编译的项目中,C和C++源文件保存在以下文件夹中,全部位于项目目录中:硬件,头文件,源文件,TCP/IP,uTasker和WinSim。当我尝试编译时,它返回以下生成日志:
1>------ Build started: Project: uTasker, Configuration: Debug Win32 ------
1>LPC17XX.obj : error LNK2019: unresolved external symbol _fnOpenDefaultHostAdapter referenced in function _fnConfigEthernet
1>WinSim.obj : error LNK2001: unresolved external symbol _iWinPcapSending
1>WinSim.obj : error LNK2019: unresolved external symbol _fnWinPcapSendPkt referenced in function _fnSimulateEthTx
1>WinSimMain.obj : error LNK2019: unresolved external symbol "void __cdecl fnDoEthereal(int,char *)" ([email protected]@[email protected]) referenced in function [email protected]
1>WinSimMain.obj : error LNK2001: unresolved external symbol "int iTxActivity" ([email protected]@3HA)
1>WinSimMain.obj : error LNK2001: unresolved external symbol "int iRxActivity" ([email protected]@3HA)
1>WinSimMain.obj : error LNK2019: unresolved external symbol "void __cdecl fnWinPcapStopLink(struct HWND__ *)" ([email protected]@[email protected]@@Z) referenced in function "long __stdcall WndProc(struct HWND__ *,unsigned int,unsigned int,long)" ([email protected]@[email protected]@[email protected])
1>WinSimMain.obj : error LNK2019: unresolved external symbol "void __cdecl fnWinPcapSelectLAN(int)" ([email protected]@[email protected]) referenced in function "long __stdcall WndProc(struct HWND__ *,unsigned int,unsigned int,long)" ([email protected]@[email protected]@[email protected])
1>WinSimMain.obj : error LNK2019: unresolved external symbol "void __cdecl fnWinPcapOpenAdapter(void)" ([email protected]@YAXXZ) referenced in function "long __stdcall SetNIC(struct HWND__ *,unsigned int,unsigned int,long)" ([email protected]@[email protected]@[email protected])
1>WinSimMain.obj : error LNK2019: unresolved external symbol "void __cdecl fnWinPcapClose(void)" ([email protected]@YAXXZ) referenced in function "long __stdcall SetNIC(struct HWND__ *,unsigned int,unsigned int,long)" ([email protected]@[email protected]@[email protected])
1>WinSimMain.obj : error LNK2019: unresolved external symbol "int __cdecl fnShowNICs(struct HWND__ *)" ([email protected]@[email protected]@@Z) referenced in function "long __stdcall SetNIC(struct HWND__ *,unsigned int,unsigned int,long)" ([email protected]@[email protected]@[email protected])
1>.\Debug\uTasker.exe : fatal error LNK1120: 11 unresolved externals
LPC17XX.c保存在Hardware/LPC17XX文件夹中。
WinSim.c和WinSimMain.cpp保存在WinSim文件夹中。
我不知道如何配置我的链接器来解决这些问题,任何帮助将不胜感激。
编辑:我正在使用Visual Studio 2010来构建项目。
您需要链接到WinPcap库。在命令行中,您可以通过添加库名称(例如winpcap.lib)作为“link”命令的一部分来完成此操作。在Visual Studio中,您将不得不围绕项目配置对话框寻找链接器设置。 – simonc
[这个问题](http://stackoverflow.com/questions/12573816/what-is-an-undefined-reference-unresolved-external-symbol-error-and-how-doi-i-fix)给你任何解决这个问题的想法? – WhozCraig
令人难以置信的问题,@WhozCraig –