Right-click your project in the Solution Explorer window and click Properties > Linker > Input > Additional Dependencies setting. You'll have to add ws2_32.lib.
The VS project templates take care of telling the linker to link the most common Windows libraries. Like kernel32.lib, you cannot write a Windows program without it. But not winsock, not every program is going to want to create a socket. That has to be added explicitly.
You can find these kind of dependencies from the MSDN article about, say, closesocket(). It is at the bottom of the article. The Header bit tells you what you need to #include, you got that right. The Library bit tells you what you need to tell the linker to link. Not automatic, you have to take care of it yourself.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…