title: Do I actually have to link Ws2_32.lib?
body: <p>All Winsock2 examples at MSDN shows that I have to statically link Winsock2 libarary as:</p>
  
  <pre><code>#pragma comment(lib, "ws2_32.lib")
  </code></pre>
  
  <blockquote>
    <p>Ensure that the build environment links to the Winsock Library file ?>Ws2_32.lib. Applications that use Winsock must be linked with the Ws2_32.lib >library file. The #pragma comment indicates to the linker that the Ws2_32.lib >file is needed.</p>
  </blockquote>
  
  <p>But why I use it instead of simple loading an existing in Windows   Ws2_32.dll (since Windows 2003 as I understand according to requirements at MSDN <a href="https://docs.microsoft.com/en-us/windows/win32/api/winsock2/nf-winsock2-recv" rel="noreferrer">https://docs.microsoft.com/en-us/windows/win32/api/winsock2/nf-winsock2-recv</a>)</p>
  
  <p>So I can use something like this:</p>
  
  <pre><code>typedef int WSAAPI(WINAPI* recv_func)(SOCKET s, char *buf, int len, int flags);
  
  HINSTANCE hGetProcIDDLL = LoadLibraryA("ws2_32.dll");
  my_recv = (recv_func)GetProcAddress(hGetProcIDDLL, "recv");
  </code></pre>
  
  <p>Or I can just use winsock2.h header and compile a program with /MD flag:</p>
  
  <pre><code>include &lt;winsock2.h&gt;
  //#pragma comment(lib, "ws2_32.lib")
  </code></pre>
  
  <p>Is it possible? Can I use /MD or load ws2_32.dll dynamically as in first example without statically linking ws2_32.lib to my application because all Windows since Win2003 have ws2_32.dll it in System32 folder?</p>