C++ Socket没有链接Ws2_32.lib错误

写用C++写Socket的时候一定要注意link  Ws2_32.lib 不然会报错误:

TcpClient.obj : error LNK2001: unresolved external symbol __imp__recv@16

TcpClient.obj : error LNK2001: unresolved external symbol __imp__send@16
TcpClient.obj : error LNK2001: unresolved external symbol __imp__connect@12
TcpClient.obj : error LNK2001: unresolved external symbol __imp__htons@4
TcpClient.obj : error LNK2001: unresolved external symbol __imp__inet_addr@4
TcpClient.obj : error LNK2001: unresolved external symbol __imp__socket@12
TcpClient.obj : error LNK2001: unresolved external symbol __imp__WSACleanup@0

TcpClient.obj : error LNK2001: unresolved external symbol __imp__WSAStartup@8

Project->Settings->Link->Object/library modules里面添加Ws2_32.lib包,包于包之间用空格隔开.

也可以用快捷键 Alt + F7 打开Project Settings界面.

你可能感兴趣的:(C++,c,socket)