zoukankan      html  css  js  c++  java
  • tcpSrv在vs2008中报错

    报错内容:

    1>LINK : warning LNK4076: 无效的增量状态文件“F:VC_projCprojDebugCproj.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_projCprojDebugCproj.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 ",recvBuf);
    //关闭套接字
    closesocket(sockConn);
    }
    return 0;
    }

    解决方法:

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

  • 相关阅读:
    【2】Java包装类
    【1】Java异常
    【10】Java多态:内部类
    【9】Java多态:接口
    【8】Java多态:抽象类(abstract关键字)
    【7】Java多态:向上转型、向下转型、instanceof运算符
    【6】Java单例模式
    元素定位工具:Chrome浏览器ChroPath插件
    linux添加环境变量
    php导出数据到多个csv并打包压缩
  • 原文地址:https://www.cnblogs.com/zhangxiujun/p/3898268.html
Copyright © 2011-2022 走看看