请教一个有关WINSOCK.DLL的问题~~~

DuMiYue 2003-10-17 09:18:50
我要用winsock编写一个通信组件(不用MFC),所以包含头文件<winsock.h>,但调用winsock函数时出现连接错误:(在VC6和VC7中都出现同样错误)
------ 已启动生成:项目:ComModule, 配置:Debug Win32 ------

正在编译...
TCPImplement.cpp
正在链接...
正在创建库 Debug/ComModule.lib 和对象 Debug/ComModule.exp
TCPImplement.obj : error LNK2019: 无法解析的外部符号 _WSACleanup@0 ,该符号在函数 "public: virtual __thiscall CTCPImplement::~CTCPImplement(void)" (??1CTCPImplement@@UAE@XZ) 中被引用
TCPImplement.obj : error LNK2019: 无法解析的外部符号 _WSAStartup@8 ,该符号在函数 "protected: int __thiscall CTCPImplement::StartupSocket(void)" (?StartupSocket@CTCPImplement@@IAEHXZ) 中被引用
TCPImplement.obj : error LNK2019: 无法解析的外部符号 _socket@12 ,该符号在函数 "protected: bool __thiscall CTCPImplement::CreateSocket(void)" (?CreateSocket@CTCPImplement@@IAE_NXZ) 中被引用
TCPImplement.obj : error LNK2019: 无法解析的外部符号 _connect@12 ,该符号在函数 "protected: bool __thiscall CTCPImplement::ConnectSocket(void)" (?ConnectSocket@CTCPImplement@@IAE_NXZ) 中被引用
TCPImplement.obj : error LNK2019: 无法解析的外部符号 _htons@4 ,该符号在函数 "protected: bool __thiscall CTCPImplement::ConnectSocket(void)" (?ConnectSocket@CTCPImplement@@IAE_NXZ) 中被引用
TCPImplement.obj : error LNK2019: 无法解析的外部符号 _WSASetLastError@4 ,该符号在函数 "protected: bool __thiscall CTCPImplement::ConnectSocket(void)" (?ConnectSocket@CTCPImplement@@IAE_NXZ) 中被引用
TCPImplement.obj : error LNK2019: 无法解析的外部符号 _gethostbyname@4 ,该符号在函数 "protected: bool __thiscall CTCPImplement::ConnectSocket(void)" (?ConnectSocket@CTCPImplement@@IAE_NXZ) 中被引用
TCPImplement.obj : error LNK2019: 无法解析的外部符号 _inet_addr@4 ,该符号在函数 "protected: bool __thiscall CTCPImplement::ConnectSocket(void)" (?ConnectSocket@CTCPImplement@@IAE_NXZ) 中被引用
TCPImplement.obj : error LNK2019: 无法解析的外部符号 _closesocket@4 ,该符号在函数 "protected: bool __thiscall CTCPImplement::CloseSocket(void)" (?CloseSocket@CTCPImplement@@IAE_NXZ) 中被引用
TCPImplement.obj : error LNK2019: 无法解析的外部符号 _WSACancelBlockingCall@0 ,该符号在函数 "protected: bool __thiscall CTCPImplement::CloseSocket(void)" (?CloseSocket@CTCPImplement@@IAE_NXZ) 中被引用
TCPImplement.obj : error LNK2019: 无法解析的外部符号 _WSAIsBlocking@0 ,该符号在函数 "protected: bool __thiscall CTCPImplement::CloseSocket(void)" (?CloseSocket@CTCPImplement@@IAE_NXZ) 中被引用
TCPImplement.obj : error LNK2019: 无法解析的外部符号 "protected: void __thiscall ACommImplement::FireError(long)" (?FireError@ACommImplement@@IAEXJ@Z) ,该符号在函数 "public: virtual int __thiscall CTCPImplement::Send(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &)" (?Send@CTCPImplement@@UAEHABV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@Z) 中被引用
TCPImplement.obj : error LNK2019: 无法解析的外部符号 _WSAGetLastError@0 ,该符号在函数 "public: virtual int __thiscall CTCPImplement::Send(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &)" (?Send@CTCPImplement@@UAEHABV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@Z) 中被引用
TCPImplement.obj : error LNK2019: 无法解析的外部符号 _send@16 ,该符号在函数 "public: virtual int __thiscall CTCPImplement::Send(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &)" (?Send@CTCPImplement@@UAEHABV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@Z) 中被引用
TCPImplement.obj : error LNK2019: 无法解析的外部符号 "protected: void __thiscall ACommImplement::FireIODataArrive(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &,int)" (?FireIODataArrive@ACommImplement@@IAEXABV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@H@Z) ,该符号在函数 "public: virtual int __thiscall CTCPImplement::Receive(int)" (?Receive@CTCPImplement@@UAEHH@Z) 中被引用
TCPImplement.obj : error LNK2019: 无法解析的外部符号 _recv@16 ,该符号在函数 "public: virtual int __thiscall CTCPImplement::Receive(int)" (?Receive@CTCPImplement@@UAEHH@Z) 中被引用
Debug/ComModule.dll : fatal error LNK1120: 16 个无法解析的外部命令

生成日志保存在“file://d:\MyProject\MyWork\ComModule\Debug\BuildLog.htm”中
ComModule - 17 错误,0 警告


---------------------- 完成 ---------------------

生成:0 已成功, 1 已失败, 0 已跳过
...全文
120 1 打赏 收藏 转发到动态 举报
写回复
用AI写文章
1 条回复
切换为时间正序
请发表友善的回复…
发表回复
hawkbird 2003-10-17
  • 打赏
  • 举报
回复
你把WS2_32.LIB加到你的项目中再编译一下,试试,怎么不用winsock2.h呢?

15,472

社区成员

发帖
与我相关
我的任务
社区描述
VC/MFC 进程/线程/DLL
社区管理员
  • 进程/线程/DLL社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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