码迷,mamicode.com
首页 > 其他好文 > 详细

tcpSrv在vs2008中报错

时间:2014-08-08 01:30:25      阅读:408      评论:0      收藏:0      [点我收藏+]

标签:blog   http   os   io   文件   数据   2014   art   

报错内容:

1>LINK : warning LNK4076: 无效的增量状态文件“F:\VC_proj\Cproj\Debug\Cproj.ilk”;正在非增量链接
1>lase.obj : error LNK2028: 无法解析的标记(0A000013) "extern "C" int __stdcall closesocket(unsigned int)" (?closesocket@@$$J14YGHI@Z),该标记在函数 "int __cdecl wmain(int,wchar_t * * const)" (?wmain@@$$HYAHHQAPA_W@Z) 中被引用
1>lase.obj : error LNK2028: 无法解析的标记(0A000016) "extern "C" int __stdcall recv(unsigned int,char *,int,int)" (?recv@@$$J216YGHIPADHH@Z),该标记在函数 "int __cdecl wmain(int,wchar_t * * const)" (?wmain@@$$HYAHHQAPA_W@Z) 中被引用
1>lase.obj : error LNK2028: 无法解析的标记(0A000018) "extern "C" int __stdcall send(unsigned int,char const *,int,int)" (?send@@$$J216YGHIPBDHH@Z),该标记在函数 "int __cdecl wmain(int,wchar_t * * const)" (?wmain@@$$HYAHHQAPA_W@Z) 中被引用
1>lase.obj : error LNK2028: 无法解析的标记(0A00001A) "extern "C" char * __stdcall inet_ntoa(struct in_addr)" (?inet_ntoa@@$$J14YGPADUin_addr@@@Z),该标记在函数 "int __cdecl wmain(int,wchar_t * * const)" (?wmain@@$$HYAHHQAPA_W@Z) 中被引用
1>lase.obj : error LNK2028: 无法解析的标记(0A00001C) "extern "C" unsigned int __stdcall accept(unsigned int,struct sockaddr *,int *)" (?accept@@$$J212YGIIPAUsockaddr@@PAH@Z),该标记在函数 "int __cdecl wmain(int,wchar_t * * const)" (?wmain@@$$HYAHHQAPA_W@Z) 中被引用
1>lase.obj : error LNK2028: 无法解析的标记(0A00001D) "extern "C" int __stdcall listen(unsigned int,int)" (?listen@@$$J18YGHIH@Z),该标记在函数 "int __cdecl wmain(int,wchar_t * * const)" (?wmain@@$$HYAHHQAPA_W@Z) 中被引用
1>lase.obj : error LNK2028: 无法解析的标记(0A00001E) "extern "C" int __stdcall bind(unsigned int,struct sockaddr const *,int)" (?bind@@$$J212YGHIPBUsockaddr@@H@Z),该标记在函数 "int __cdecl wmain(int,wchar_t * * const)" (?wmain@@$$HYAHHQAPA_W@Z) 中被引用
1>lase.obj : error LNK2028: 无法解析的标记(0A00001F) "extern "C" unsigned short __stdcall htons(unsigned short)" (?htons@@$$J14YGGG@Z),该标记在函数 "int __cdecl wmain(int,wchar_t * * const)" (?wmain@@$$HYAHHQAPA_W@Z) 中被引用
1>lase.obj : error LNK2028: 无法解析的标记(0A000020) "extern "C" unsigned long __stdcall htonl(unsigned long)" (?htonl@@$$J14YGKK@Z),该标记在函数 "int __cdecl wmain(int,wchar_t * * const)" (?wmain@@$$HYAHHQAPA_W@Z) 中被引用
1>lase.obj : error LNK2028: 无法解析的标记(0A000021) "extern "C" unsigned int __stdcall socket(int,int,int)" (?socket@@$$J212YGIHHH@Z),该标记在函数 "int __cdecl wmain(int,wchar_t * * const)" (?wmain@@$$HYAHHQAPA_W@Z) 中被引用
1>lase.obj : error LNK2028: 无法解析的标记(0A000022) "extern "C" int __stdcall WSACleanup(void)" (?WSACleanup@@$$J10YGHXZ),该标记在函数 "int __cdecl wmain(int,wchar_t * * const)" (?wmain@@$$HYAHHQAPA_W@Z) 中被引用
1>lase.obj : error LNK2028: 无法解析的标记(0A000023) "extern "C" int __stdcall WSAStartup(unsigned short,struct WSAData *)" (?WSAStartup@@$$J18YGHGPAUWSAData@@@Z),该标记在函数 "int __cdecl wmain(int,wchar_t * * const)" (?wmain@@$$HYAHHQAPA_W@Z) 中被引用
1>lase.obj : error LNK2019: 无法解析的外部符号 "extern "C" int __stdcall closesocket(unsigned int)" (?closesocket@@$$J14YGHI@Z),该符号在函数 "int __cdecl wmain(int,wchar_t * * const)" (?wmain@@$$HYAHHQAPA_W@Z) 中被引用
1>lase.obj : error LNK2019: 无法解析的外部符号 "extern "C" int __stdcall recv(unsigned int,char *,int,int)" (?recv@@$$J216YGHIPADHH@Z),该符号在函数 "int __cdecl wmain(int,wchar_t * * const)" (?wmain@@$$HYAHHQAPA_W@Z) 中被引用
1>lase.obj : error LNK2019: 无法解析的外部符号 "extern "C" int __stdcall send(unsigned int,char const *,int,int)" (?send@@$$J216YGHIPBDHH@Z),该符号在函数 "int __cdecl wmain(int,wchar_t * * const)" (?wmain@@$$HYAHHQAPA_W@Z) 中被引用
1>lase.obj : error LNK2019: 无法解析的外部符号 "extern "C" char * __stdcall inet_ntoa(struct in_addr)" (?inet_ntoa@@$$J14YGPADUin_addr@@@Z),该符号在函数 "int __cdecl wmain(int,wchar_t * * const)" (?wmain@@$$HYAHHQAPA_W@Z) 中被引用
1>lase.obj : error LNK2019: 无法解析的外部符号 "extern "C" unsigned int __stdcall accept(unsigned int,struct sockaddr *,int *)" (?accept@@$$J212YGIIPAUsockaddr@@PAH@Z),该符号在函数 "int __cdecl wmain(int,wchar_t * * const)" (?wmain@@$$HYAHHQAPA_W@Z) 中被引用
1>lase.obj : error LNK2019: 无法解析的外部符号 "extern "C" int __stdcall listen(unsigned int,int)" (?listen@@$$J18YGHIH@Z),该符号在函数 "int __cdecl wmain(int,wchar_t * * const)" (?wmain@@$$HYAHHQAPA_W@Z) 中被引用
1>lase.obj : error LNK2019: 无法解析的外部符号 "extern "C" int __stdcall bind(unsigned int,struct sockaddr const *,int)" (?bind@@$$J212YGHIPBUsockaddr@@H@Z),该符号在函数 "int __cdecl wmain(int,wchar_t * * const)" (?wmain@@$$HYAHHQAPA_W@Z) 中被引用
1>lase.obj : error LNK2019: 无法解析的外部符号 "extern "C" unsigned short __stdcall htons(unsigned short)" (?htons@@$$J14YGGG@Z),该符号在函数 "int __cdecl wmain(int,wchar_t * * const)" (?wmain@@$$HYAHHQAPA_W@Z) 中被引用
1>lase.obj : error LNK2019: 无法解析的外部符号 "extern "C" unsigned long __stdcall htonl(unsigned long)" (?htonl@@$$J14YGKK@Z),该符号在函数 "int __cdecl wmain(int,wchar_t * * const)" (?wmain@@$$HYAHHQAPA_W@Z) 中被引用
1>lase.obj : error LNK2019: 无法解析的外部符号 "extern "C" unsigned int __stdcall socket(int,int,int)" (?socket@@$$J212YGIHHH@Z),该符号在函数 "int __cdecl wmain(int,wchar_t * * const)" (?wmain@@$$HYAHHQAPA_W@Z) 中被引用
1>lase.obj : error LNK2019: 无法解析的外部符号 "extern "C" int __stdcall WSACleanup(void)" (?WSACleanup@@$$J10YGHXZ),该符号在函数 "int __cdecl wmain(int,wchar_t * * const)" (?wmain@@$$HYAHHQAPA_W@Z) 中被引用
1>lase.obj : error LNK2019: 无法解析的外部符号 "extern "C" int __stdcall WSAStartup(unsigned short,struct WSAData *)" (?WSAStartup@@$$J18YGHGPAUWSAData@@@Z),该符号在函数 "int __cdecl wmain(int,wchar_t * * const)" (?wmain@@$$HYAHHQAPA_W@Z) 中被引用
1>F:\VC_proj\Cproj\Debug\Cproj.exe : fatal error LNK1120: 24 个无法解析的外部命令

源码:

#include <stdafx.h>
#include <Winsock2.h>
#include <stdio.h>

int _tmain(int argc, _TCHAR* argv[])
{
//加载套接字库
WORD wVersionRequested;
WSADATA wsaData;
int err;
wVersionRequested = MAKEWORD(1,1);
err=WSAStartup(wVersionRequested, &wsaData);
if(err!=0)
{
return 0 ;
}
if(LOBYTE(wsaData.wVersion)!=1 ||
HIBYTE(wsaData.wVersion)!=1 )
{
WSACleanup();
return 0;
}

//创建用于监听的套接字
SOCKET sockSrv=socket(AF_INET,SOCK_STREAM,0);
SOCKADDR_IN addrSrv;
addrSrv.sin_addr.S_un.S_addr=htonl(INADDR_ANY);
addrSrv.sin_family=AF_INET;
addrSrv.sin_port=htons(6000);

//绑定套接字
bind(sockSrv,(SOCKADDR*)&addrSrv,sizeof(SOCKADDR));
//将套接字设为监听模式,准备接收客户请求
listen(sockSrv,5);

SOCKADDR_IN addrClient;
int len = sizeof(SOCKADDR);
while(1)
{
SOCKET sockConn=accept(sockSrv,(SOCKADDR*)&addrClient,&len);
char sendBuf[100];
sprintf(sendBuf,"Welcome %s to here",inet_ntoa(addrClient.sin_addr));
//发送数据
send(sockConn,sendBuf,strlen(sendBuf)+1,0);
char recvBuf[100];
//接收数据
recv(sockConn,recvBuf,100,0);
//打印接收的数据
printf("%s \n",recvBuf);
//关闭套接字
closesocket(sockConn);
}
return 0;
}

解决方法:

项目->xx属性->配置属性->命令行->附加选项(也就是添加静态连接库的地方)ws2_32.lib

bubuko.com,布布扣

tcpSrv在vs2008中报错,布布扣,bubuko.com

tcpSrv在vs2008中报错

标签:blog   http   os   io   文件   数据   2014   art   

原文地址:http://www.cnblogs.com/zhangxiujun/p/3898268.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!