error LNK2001: unresolved external symbol __imp__closesocket@4

环境:Visual C++6.0

问题:链接错误

描述:

Linking...

NetSrv.obj : error LNK2001: unresolvedexternal symbol __imp__closesocket@4

NetSrv.obj : error LNK2001: unresolvedexternal symbol __imp__inet_ntoa@4

NetSrv.obj : error LNK2001: unresolvedexternal symbol __imp__sendto@24

NetSrv.obj : error LNK2001: unresolvedexternal symbol __imp__recvfrom@24

NetSrv.obj : error LNK2001: unresolvedexternal symbol __imp__bind@12

NetSrv.obj : error LNK2001: unresolvedexternal symbol __imp__htons@4

NetSrv.obj : error LNK2001: unresolvedexternal symbol __imp__htonl@4

NetSrv.obj : error LNK2001: unresolvedexternal symbol __imp__socket@12

NetSrv.obj : error LNK2001: unresolvedexternal symbol __imp__WSACleanup@0

NetSrv.obj : error LNK2001: unresolvedexternal symbol __imp__WSAStartup@8

Debug/NetSrv.exe : fatal error LNK1120: 10unresolved externals

Error executing link.exe.

NetSrv.exe - 11 error(s), 0 warning(s)

分析:编译无错,连接有错,第一种是函数有声明但没有具体的实现,第二种是没有加载到所需要的动态链接库(lib库)。本问题属于第二种情况。

  解决:

  (1)加入头文件:#include

  (2)菜单栏--->project---->Settings---->Link标签页---->Object/library modules---->加入ws2_32.lib---->重新编译连接---->解决。

你可能感兴趣的:(error LNK2001: unresolved external symbol __imp__closesocket@4)