0
votes

I am trying window socket programming in c++.I am using winsock2.h for this purpose.i am doing this in code blocks using GNU GCC and getting errors as shown in attachment as you can see.This is important to know that I trying just client server model. I am not putting my code here because code is available on msdn(I have just copied from there).I am just providing link

Server code https://msdn.microsoft.com/en-us/library/windows/desktop/ms737593(v=vs.85).aspx

client code https://msdn.microsoft.com/en-us/library/windows/desktop/ms737591(v=vs.85).aspx

enter image description here

1

1 Answers

1
votes

Posted a comment, but confident enough to make an answer...

The screenshot you included shows Linker errors, so everything is probably compiling correctly. To use WinSock2, your program must link with Ws2_32.lib, which is a standard system library included with the Windows SDK.

SDK stands for Software Development Kit. It contains many header files and libraries that are needed to write software for Windows. Sorry if this is too basic, but... You included the header file WinSock2.h. That header only includes the declarations for all the WinSock functions - just a description of the functions. The function definitions (the code for the functions) is located in a library that you have to "link" with. In some cases you will get source code for a library that you can compile with, but most of the time you will only get a pre-compiled LIB file such as Ws2_32.lib. The Windows SDK contains the LIB files for most of the programs you can write for Windows.

For more information search for "linking", "Win32 libraries", and "dynamic link libraries" (DLLs).