How to link winsock.lib?

Safari picture Safari · Feb 12, 2012 · Viewed 49.2k times · Source

In my C++ class, I use sockets.

I have some errors when linking because, in my opinion, the library winsock.lib is missing.

I included these:

#ifdef WIN32
  #include <winsock.h>         
  typedef int socklen_t;
  typedef char raw_type;       
#endif

How can I link the library winsock.lib? I use Windows XP and Visual Studio 2005.

Answer

ciphor picture ciphor · Feb 12, 2012

The lib file of winsock is "ws_32.lib" (or "ws2_32.lib"), please make sure you've added it.