project->settings->link 在object/library modules 中加入ws2_32.lib
在项目上点右键->属性->配置属性->链接器->输入->附加依赖项加入ws2_32.lib
如:
error LNK2001: unresolved external symbol __imp__send@16
tcpclient.obj : error LNK2001: unresolved external symbol __imp__closesocket@4
tcpclient.obj : error LNK2001: unresolved external symbol __imp__connect@12
tcpclient.obj : error LNK2001: unresolved external symbol __imp__inet_ntoa@4
tcpclient.obj : error LNK2001: unresolved external symbol __imp__inet_addr@4
tcpclient.obj : error LNK2001: unresolved external symbol __imp__htons@4
tcpclient.obj : error LNK2001: unresolved external symbol __imp__WSACleanup@0
tcpclient.obj : error LNK2001: unresolved external symbol __imp__WSAGetLastError@0
tcpclient.obj : error LNK2001: unresolved external symbol __imp__socket@12
tcpclient.obj : error LNK2001: unresolved extern
在项目上点右键->属性->配置属性->链接器->输入->附加依赖项加入ws2_32.lib
如:
error LNK2001: unresolved external symbol __imp__send@16
tcpclient.obj : error LNK2001: unresolved external symbol __imp__closesocket@4
tcpclient.obj : error LNK2001: unresolved external symbol __imp__connect@12
tcpclient.obj : error LNK2001: unresolved external symbol __imp__inet_ntoa@4
tcpclient.obj : error LNK2001: unresolved external symbol __imp__inet_addr@4
tcpclient.obj : error LNK2001: unresolved external symbol __imp__htons@4
tcpclient.obj : error LNK2001: unresolved external symbol __imp__WSACleanup@0
tcpclient.obj : error LNK2001: unresolved external symbol __imp__WSAGetLastError@0
tcpclient.obj : error LNK2001: unresolved external symbol __imp__socket@12
tcpclient.obj : error LNK2001: unresolved extern

当遇到未解析的外部符号错误时,如send@16等,需要在项目设置中将ws2_32.lib加入链接器的附加依赖项。ws2_32.lib提供对多种网络API的支持,如accept、bind、connect等。确保正确链接以避免编译错误。
最低0.47元/天 解锁文章

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



