title: How to fix undefined reference to `_imp__pthread_create'
body: <p>I use MinGW on windows7 32bit.
  And I can’t compile my source which uses pthread.</p>
  
  <p>My code is below.</p>
  
  <pre><code>#include &lt;stdio.h&gt;
  #include &lt;pthread.h&gt;
  
  int main(int argc, char** argv)
  {
    (void)argv;
    printf("######## start \n");
  #ifndef pthread_create
    return ((int*)(&amp;pthread_create))[argc];
  #else
    (void)argc;
    return 0;
  #endif
  }
  </code></pre>
  
  <p>Error happens as I compile it.</p>
  
  <pre><code>gcc -I /usr/local/include -L /usr/local/lib/libpthread.dll.a trylpthread.c
  C:\Users\xxx\AppData\Local\Temp\cc9OVt5b.o:trylpthread.c:(.text+0x25): undefined reference to `_imp__pthread_create'
  collect2.exe: error: ld returned 1 exit status
  </code></pre>
  
  <p>I use following pthread library.</p>
  
  <p><code>pthreads-w32-2.8.0-3-mingw32-dev</code></p>
  
  <p>And here is libpthread.dll.a in /usr/local/lib</p>
  
  <p>Does anyone know how to fix this problem?</p>