title: Autoconf - No POSIX thread support. Configure possibly using wrong code to verify support. How to fix it?
body: <p>I am using ./configure to configure one of the projects. I get the following error from it.</p>
  
  <pre><code>checking for the pthreads library -lpthreads... no
  checking whether pthreads work without any flags... no
  checking whether pthreads work with -Kthread... no
  checking whether pthreads work with -kthread... no
  checking for the pthreads library -llthread... no
  checking whether pthreads work with -pthread... no
  checking whether pthreads work with -pthreads... no
  checking whether pthreads work with -mthreads... no
  checking for the pthreads library -lpthread... no
  checking whether pthreads work with --thread-safe... no
  checking whether pthreads work with -mt... no
  checking for pthread-config... no
  configure: error: POSIX threads support is required
  </code></pre>
  
  <p>When I check the configure file, I see that it is using the following code to check for pthread support:</p>
  
  <pre><code>#include &lt;pthread.h&gt;
  int main ()
  {
  pthread_t th; pthread_join(th, 0);
                       pthread_attr_init(0); pthread_cleanup_push(0, 0);
                       pthread_create(0,0,0,0); pthread_cleanup_pop(0);
    ;
    return 0;
  }
  </code></pre>
  
  <p>When I compile it seperately, it does compile. But with warnings from pthread_create. </p>
  
  <pre><code>test_pthread.c:5:22: warning: null argument where non-null required (argument 1) [-Wnonnull]
                        pthread_attr_init(0); pthread_cleanup_push(0, 0);
                        ^
  test_pthread.c:6:22: warning: null argument where non-null required (argument 1) [-Wnonnull]
                        pthread_create(0,0,0,0); pthread_cleanup_pop(0);
                        ^
  test_pthread.c:6:22: warning: null argument where non-null required (argument 3) [-Wnonnull]
  </code></pre>
  
  <p>Is this a bug in the way configure is checking for -pthread support with the compiler? How can I fix this?</p>
  
  <p>I am using autoreconf -i before I run ./configure. What is a clean way to fix this issue?</p>
  
  <p>------------ EDIT: Adding More Info ----------</p>
  
  <p>I am using the following Lines in the configure.ac file to check for pthread. I just got it from a config online.</p>
  
  <pre><code># Check for POSIX thread support
  
      ACX_PTHREAD([
                       LIBS="$LIBS $PTHREAD_LIBS"
                       CFLAGS="$CFLAGS $PTHREAD_CFLAGS -g -Wall"
                       CC="$PTHREAD_CC"
                       AC_SUBST([LIBS])
                       AC_SUBST([CFLAGS])
                       AC_SUBST([CC])
                   ],
                   [AC_MSG_ERROR([POSIX threads support is required])])
  </code></pre>