-1

I am using ./configure to configure one of the projects. I get the following error from it.

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

When I check the configure file, I see that it is using the following code to check for pthread support:

#include <pthread.h>
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;
}

When I compile it seperately, it does compile. But with warnings from pthread_create.

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]

Is this a bug in the way configure is checking for -pthread support with the compiler? How can I fix this?

I am using autoreconf -i before I run ./configure. What is a clean way to fix this issue?

------------ EDIT: Adding More Info ----------

I am using the following Lines in the configure.ac file to check for pthread. I just got it from a config online.

# 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])])
  • The warnings shouldn't stop the test from succeeding. You'll need to include in the question more of the autoconf source file that implements those tests. – caf May 06 '16 at 00:44
  • @caf: Adding the lines of code I use in the configure.ac file. –  May 06 '16 at 01:29
  • You haven't set `-Werror` in your CFLAGS prior to this point have you? – caf May 06 '16 at 02:03
  • Well yes I have. Is it possible to ignore the warnings only for the -pthread library. Something I can add to the configure.ac file? –  May 06 '16 at 18:46

1 Answers1

1

From comments it is apparent that you have set -Werror in your CFLAGS early in your autoconf script.

Don't do that. If you want -Werror, add it to CFLAGS right at the end of the script, after all tests that invoke the compiler have been run. Most autoconf tests are not written to work with -Werror.

caf
  • 233,326
  • 40
  • 323
  • 462