Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to link winsock.lib?

Tags:

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.

like image 898
Safari Avatar asked Feb 12 '12 15:02

Safari


People also ask

How do I use Winsock in Visual Studio?

To create a basic Winsock applicationCreate a new empty project. Add an empty C++ source file to the project. Ensure that the build environment refers to the Include, Lib, and Src directories of the Microsoft Windows Software Development Kit (SDK) or the earlier Platform Software Development Kit (SDK).

What is ws2_32 lib?

The library ws2_32. lib is an import library.

What is Winsock2 h?

Socket type definitions in the Winsock2. h and Ws2def. h header files will be periodically updated as new socket types, address families, and protocols are defined. In Windows Sockets 1.1, the only possible socket types are SOCK_DGRAM and SOCK_STREAM.


2 Answers

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

like image 175
ciphor Avatar answered Sep 21 '22 10:09

ciphor


I am unable to find direct link shows what lib to use, but if you study this, you will find out, that windows sockets 1.1 is supported through WSOCK32.DLL, that mean, possible, that you want WSock32.Lib, instead of Ws2_32.lib for windows socket version 2.

WSock32.Lib is a part of Windows SDK (I have v6.0A, v7.0A installed, both has this library)

like image 30
Lol4t0 Avatar answered Sep 25 '22 10:09

Lol4t0