一个让人头疼的简单问题!!(急,在线等)

zhang5765 2004-05-07 01:05:52
我在vs.net环境中写一个网络连接程序,但是连接总是有错,其中一些错误为
正在编译...
stdafx.cpp
正在编译...
test.cpp
AssemblyInfo.cpp
正在生成代码...
正在编译资源...
正在链接...
test.obj : error LNK2001: 无法解析的外部符号 "int __stdcall WSACleanup(void)" (?WSACleanup@@$$J10YGHXZ)
test.obj : error LNK2001: 无法解析的外部符号 "int __stdcall closesocket(unsigned int)" (?closesocket@@$$J14YGHI@Z)
test.obj : error LNK2001: 无法解析的外部符号 "int __stdcall recv(unsigned int,char *,int,int)" (?recv@@$$J216YGHIPADHH@Z)
test.obj : error LNK2001: 无法解析的外部符号 "int __stdcall send(unsigned int,char const *,int,int)" (?send@@$$J216YGHIPBDHH@Z)
test.obj : error LNK2001: 无法解析的外部符号 "int __stdcall connect(unsigned int,struct sockaddr const *,int)" (?connect@@$$J212YGHIPBUsockaddr@@H@Z)
test.obj : error LNK2001: 无法解析的外部符号 "unsigned int __stdcall socket(int,int,int)" (?socket@@$$J212YGIHHH@Z)
test.obj : error LNK2001: 无法解析的外部符号 "unsigned short __stdcall htons(unsigned short)" (?htons@@$$J14YGGG@Z)
test.obj : error LNK2001: 无法解析的外部符号 "int __stdcall WSAGetLastError(void)" (?WSAGetLastError@@$$J10YGHXZ)
test.obj : error LNK2001: 无法解析的外部符号 "struct hostent * __stdcall gethostbyaddr(char const *,int,int)" (?gethostbyaddr@@$$J212YGPAUhostent@@PBDHH@Z)
test.obj : error LNK2001: 无法解析的外部符号 "unsigned long __stdcall inet_addr(char const *)" (?inet_addr@@$$J14YGKPBD@Z)
test.obj : error LNK2001: 无法解析的外部符号 "struct hostent * __stdcall gethostbyname(char const *)" (?gethostbyname@@$$J14YGPAUhostent@@PBD@Z)
test.obj : error LNK2001: 无法解析的外部符号 "int __stdcall WSAStartup(unsigned short,struct WSAData *)" (?WSAStartup@@$$J18YGHGPAUWSAData@@@Z)
E:\zhuzi\test\Debug\test.exe : fatal error LNK1120: 12 个无法解析的外部命令
//////////////////////////////////////////////////////////////////////
说明:
我程序的开始我包含了:
#include <winsock2.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
最后请高手给予帮助。
另:分不够可以在加!!!!
...全文
103 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
zhang5765 2004-05-07
  • 打赏
  • 举报
回复
请问楼上能给具体做法吗?
(我先自己试一试)
COM_MOC 2004-05-07
  • 打赏
  • 举报
回复
链接出错,应该是没有将需要乃至的lib添加到设置中。
应该在设置里添加ws2_32.lib,将ws2_32.lib添加到工程里应该也可以的。
zhang5765 2004-05-07
  • 打赏
  • 举报
回复
自己先up!!

4,356

社区成员

发帖
与我相关
我的任务
社区描述
通信技术相关讨论
社区管理员
  • 网络通信
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧