一个控制台程序,想在里边使用SOCKET,怎么办?我已经include <winsock2.h>
可是编译还是出现如下错误:
consolesock.obj : error LNK2001: unresolved external symbol __imp__WSAStartup@8源程序如下;#include "stdafx.h"
#include "consolesock.h"
#include "winsock2.h" CWinApp theApp;
using namespace std;int _tmain(int argc, TCHAR* argv[], TCHAR* envp[])
{
    WSADATA wsaData;//协商版本号时要用到的变量
    int nRetCode = 0;
    if (!AfxWinInit(::GetModuleHandle(NULL), NULL, ::GetCommandLine(), 0))
    {
cerr << _T("Fatal Error: MFC initialization failed") << endl;
nRetCode = 1;
    }
    else
    {
//启动动态链接库并协商其版本号
if(WSAStartup(MAKEWORD(2, 2), &wsaData) != 0)
{
cerr<<_T("Fatal:Winsock initiation failed!\n");
return -1;
}
    }
    return nRetCode;
}