Why am I getting linker errors for ws2_32.dll in my C program?

Sanjay picture Sanjay · Mar 7, 2011 · Viewed 15.1k times · Source

I am writing my program in Visual Studio 2010. I am unable to link a file named ws2_32.dll with my project.

Can anyone tell me how I can do that?

Answer

Bernd Elkemann picture Bernd Elkemann · Mar 7, 2011

Typically you dont link to ws2_32.dll directly but to WS2_32.Lib, which you can find in the Windows SDK. So in your code you write

#include <winsock2.h>

and to your linker-settings you add WS2_32.Lib and you're good to go.

The Windows SDK is here:

http://msdn.microsoft.com/en-us/windows/bb980924.aspx