title: pthread_create return error on compiling
body: <p>I have used the following code to create two threads:</p>
  
  <pre><code>//header files
  #include &lt;pthread.h&gt;
  struct thread_arg
  {
      int var1;
      int var2;
  };
  void *serv_com(void *pass_arg)
  {
      struct thread_arg *con = pass_arg;
      //required statements irrelevant to the issue
      pthread_exit(NULL);
  }
  void *cli_com(void *pass_arg)
  {
      struct thread_arg *con = pass_arg;
      //required statements irrelevant to the issue
      pthread_exit(NULL);
  }
  int main()
  {
      pthread_t inter_com;
      //necessary code
      while(1)
      {
          th_err_s = pthread_create(&amp;inter_com, NULL, serv_com, (void *)&amp;pass_arg);
          th_err_c = pthread_create(&amp;inter_com, NULL, cli_com, (void *)&amp;pass_arg);
          if (th_err_s || th_err_c)
          {
              printf("Alert! Error creating thread! Exiting Now!");
              exit(-1);
          }
      }
      pthread_exit(NULL);
      return 1;
  }
  </code></pre>
  
  <p>Then I compiled the above code in linux using the following command:</p>
  
  <pre><code>gcc -o sample sample.c
  </code></pre>
  
  <p>It returned the following error message:</p>
  
  <pre><code>inter.c:(.text+0x374): undefined reference to `pthread_create'
  inter.c:(.text+0x398): undefined reference to `pthread_create'
  collect2: ld returned 1 exit status
  </code></pre>
  
  <p>What should I do to correctly compile this file. I am sure it is no syntax error or anything since when I commented off everything inside the while loop, the program was compiling correctly and I verified that the pthread_create syntax is correct. Do I have to issue some other command to compile the file?</p>
  
  <p>EDIT: Is there any problem with the creating of two threads in the above code? The program is just exiting with the error message once it is running. What can be the possible issue and how can I solve it? Thanks in advance.</p>