title: undefined reference to pthread_create and pthread_join
body: <p>I am trying to build my program but keep getting the same error messages: </p>
  
  <pre><code>undefined reference to pthread_create  
  undefined reference to pthread_join
  </code></pre>
  
  <p>I have included pthread.h and in my makefile im compiling with <code>-pthread</code>.</p>
  
  <pre><code>int threadAmount = strtol(nrthr, NULL, 0);
      threadAmount--;
  
      if(threadAmount &gt; 0){
          pthread_t tids[threadAmount];
  
          for(int i = 0;i &lt; threadAmount; i++){
              pthread_attr_t attr;
              pthread_attr_init(&amp;attr);
              pthread_create(&amp;tids[i],&amp;attr,search,&amp;t1);
          }
  
          for(int i = 0;i &lt; threadAmount; i++){
              pthread_join(tids[i],NULL);
          }
      }
  </code></pre>
  
  <p>It's where I'm calling create and join where it's complaining. What could be the problem?</p>
  
  <p>The makefile used to build:</p>
  
  <pre><code>CC=gcc
  CFLAGS= -pthread -std=gnu11 -Wall -Wextra -Werror -Wmissing-declarations -Wmissing-prototypes -Werror-implicit-function-declaration -Wreturn-type -Wparentheses -Wunused -Wold-style-definition -Wundef -Wshadow -Wstrict-prototypes -Wswitch-default -Wunreachable-code
  
  all: mfind
  
  list.o: list.c list.h
      $(CC) -c list.c $(CFLAGS)
  
  mfind.o: mfind.c list.h
      $(CC) -c mfind.c $(CFLAGS) 
  
  mfind: mfind.o list.o
      $(CC) mfind.o list.o -o mfind
  
  clean:
      rm -f *.o mfind
  </code></pre>
  
  <p><code>mfind</code> is the main program and <code>list.c</code> is an implemented list.</p>