1.问题现象如下:
serverDlg.obj : error LNK2001: unresolved external symbol __imp__listen@8
serverDlg.obj : error LNK2001: unresolved external symbol __imp__bind@12
serverDlg.obj : error LNK2001: unresolved external symbol __imp__socket@12
serverDlg.obj : error LNK2001: unresolved external symbol __imp__WSAStartup@8
serverDlg.obj : error LNK2001: unresolved external symbol __imp__inet_addr@4
serverDlg.obj : error LNK2001: unresolved external symbol __imp__htons@4
serverDlg.obj : error LNK2001: unresolved external symbol __imp__recv@16
serverDlg.obj : error LNK2001: unresolved external symbol __imp__WSAGetLastError@0
serverDlg.obj : error LNK2001: unresolved external symbol __imp__accept@12
serverDlg.obj : error LNK2001: unresolved external symbol __imp__closesocket@4
serverDlg.obj : error LNK2001: unresolved external symbol __imp__send@16
Debug/server.exe : fatal error LNK1120: 11 unresolved externals
Error executing link.exe.
解决办法:
有两种方法可以解决这个问题
1.在project->setting中,打开link选项卡,加上ws2_32.lib
2.在文件中加上#pragma comment(lib, "ws2_32.lib")