error LNK2019: 无法解析的外部符号 _socket@12,该符号在函数 _wmain 中被引用

Reason: 学习使用socket,在stdafx.h文件加了#include ,编译

#include "stdafx.h"

#include

using namespace std;

int _tmain(int argc, _TCHAR* argv[]) {

    int socketId;

    socketId = socket(AF_INET, SOCK_STREAM, 0);

    return 0;

}

Error: error LNK2019: 无法解析的外部符号 _socket@12,该符号在函数 _wmain 中被引用

Solution: 项目->属性->配置属性->连接器->输入->附加依赖项”里添加“ws2_32.lib”

error <wbr>LNK2019: <wbr>无法解析的外部符号 <wbr>_socket@12,该符号在函数 <wbr>_wmain <wbr>中被引用
 

参考自:http://blog.csdn.net/w174504744/article/details/7368169

猜你喜欢

转载自blog.csdn.net/qq1841370452/article/details/82721549