title: undefined reference to `__imp_WSAStartup' in linux
body: <p>Hi I want to build an application for windows in <code>C</code>, I program in linux and compile the code with <code>gcc</code> and <code>mingw-w64</code>.</p>
  
  <p>I tried a simple program with output and input it works fine on windows.</p>
  
  <p>But, I want to use sockets to connect to a server.</p>
  
  <p>So I searched in google and found this tutorial <a href="http://beej.us/guide/bgnet/output/html/multipage/intro.html#audience" rel="nofollow noreferrer">http://beej.us/guide/bgnet/output/html/multipage/intro.html#audience</a></p>
  
  <p>It says that in windows we need to include <code>winsock</code> and run some command
  So I did:</p>
  
  <pre><code>#include &lt;winsock.h&gt;
  int main(void)
  {
      WSADATA wsaData;
      printf("Hello! This is a test prgoram.\n");
      if (WSAStartup(MAKEWORD(1,1), &amp;wsaData) != 0) {
          fprintf(stderr, "WSAStartup failed.\n");
      }
  }
  </code></pre>
  
  <p>But when I try to compile it I get:</p>
  
  <blockquote>
    <p>undefined reference to `__imp_WSAStartup'
    collect2: error: ld returned 1 exit status</p>
  </blockquote>
  
  <p>In command line all that I run was:</p>
  
  <pre><code>x86_64-w64-mingw32-gcc try.c -o a.exe
  </code></pre>
  
  <p>So what I should do? 
  If I compile in linux I don't need the <code>winsock</code> library?
  How to fix this?</p>
  
  <p>thanks</p>