我在程序Lan中使用了winsock函数,出现如下错误:
Lan.obj:error LNK2001: unresolved external symbol __imp__listen@8
Lan.obj : error LNK2001: unresolved external symbol __imp__bind@12
Lan.obj : error LNK2001: unresolved external symbol __imp__setsockopt@20
Lan.obj : error LNK2001: unresolved external symbol __imp__htons@4
Lan.obj : error LNK2001: unresolved external symbol __imp__WSAAsyncSelect@16
Lan.obj : error LNK2001: unresolved external symbol __imp__socket@12
Lan.obj : error LNK2001: unresolved external symbol __imp__connect@12
Lan.obj : error LNK2001: unresolved external symbol __imp__gethostbyname@4
Lan.obj : error LNK2001: unresolved external symbol __imp__inet_addr@4
Lan.obj : error LNK2001: unresolved external symbol __imp__accept@12
Lan.obj : error LNK2001: unresolved external symbol __imp__gethostname@8
Lan.obj : error LNK2001: unresolved external symbol __imp__closesocket@4
Debug/Transport.exe : fatal error LNK1120: 12 unresolved externals
Error executing link.exe.
Lan.obj:error LNK2001: unresolved external symbol __imp__listen@8
Lan.obj : error LNK2001: unresolved external symbol __imp__bind@12
Lan.obj : error LNK2001: unresolved external symbol __imp__setsockopt@20
Lan.obj : error LNK2001: unresolved external symbol __imp__htons@4
Lan.obj : error LNK2001: unresolved external symbol __imp__WSAAsyncSelect@16
Lan.obj : error LNK2001: unresolved external symbol __imp__socket@12
Lan.obj : error LNK2001: unresolved external symbol __imp__connect@12
Lan.obj : error LNK2001: unresolved external symbol __imp__gethostbyname@4
Lan.obj : error LNK2001: unresolved external symbol __imp__inet_addr@4
Lan.obj : error LNK2001: unresolved external symbol __imp__accept@12
Lan.obj : error LNK2001: unresolved external symbol __imp__gethostname@8
Lan.obj : error LNK2001: unresolved external symbol __imp__closesocket@4
Debug/Transport.exe : fatal error LNK1120: 12 unresolved externals
Error executing link.exe.
解决方法:
[Project->
Setting]-> [Link-> Object/Library modules]加入wsock32.lib
本文解决了在使用Winsock函数时遇到的未解析外部符号错误。通过在项目设置中的链接器模块列表添加wsock32.lib库文件,成功解决了所有提到的函数链接问题。
233

被折叠的 条评论
为什么被折叠?



