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”