当前位置:网站首页>【QT】capture. Obj:-1: error: lnk2019: unresolved external symbols__ imp_ Htons (solution)

【QT】capture. Obj:-1: error: lnk2019: unresolved external symbols__ imp_ Htons (solution)

2022-07-27 07:38:00 Cappuccino-jay

In use QT The following error was encountered during socket programming :


1、capture.obj error: LNK2019: Unresolved external symbols __imp_htons, The sign is in the function “public: int __cdecl Capture::ipPackageHandle(unsigned char const *,int &)” ([email protected]@@[email protected]) Cited in
2、capture.obj error: LNK2019: Unresolved external symbols __imp_ntohl, The sign is in the function “public: int __cdecl Capture::tcpPackageHandle(unsigned char const *,class QString &,int)” ([email protected]@@[email protected]@[email protected]) Cited in
3、capture.obj error: LNK2019: Unresolved external symbols __imp_ntohs, The sign is in the function “public: int __cdecl Capture::ethernetPackageHandle(unsigned char const *,class QString &)” ([email protected]@@[email protected]@@Z) Cited in
4、datapackage.obj error: LNK2019: Unresolved external symbols htonl, The sign is in the function “public: bool __cdecl DataPackage::getTcpOperationSACK(int,unsigned char &,class QVector &)” ([email protected]@@[email protected]@@@Z) Cited in
5、datapackage.obj error: LNK2019: Unresolved external symbols inet_ntoa, The sign is in the function “public: class QString __cdecl DataPackage::getDesIpAddr(void)” ([email protected]@@[email protected]@XZ) Cited in
6、datapackage.obj error: LNK2019: Unresolved external symbols ntohl, The sign is in the function “public: class QString __cdecl DataPackage::getTcpSequence(void)” ([email protected]@@[email protected]@XZ) Cited in
7、datapackage.obj error: LNK2019: Unresolved external symbols ntohs, The sign is in the function “public: class QString __cdecl DataPackage::getMacType(void)” ([email protected]@@[email protected]@XZ) Cited in
8、debug\shark.exe error: LNK1120: 7 Unresolved external commands


 Insert picture description here

The solution is as follows :

stay CPP file include Add the following code after the statement :

#pragma comment(lib,"ws2_32.lib")

Indicates when the link is found ws2_32.lib

Then the compilation succeeds :
 Insert picture description here

原网站

版权声明
本文为[Cappuccino-jay]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/208/202207270604337561.html