[PATCH] tests: Fix undefined reference to 'pthread_create'

Clemens Lang cllang at redhat.com
Thu Feb 10 14:38:44 CET 2022


* configure.ac (HAVE_PTHREAD): Expose as AM_CONDITIONAL for use in
  Makefile.am
* tests/Makefile.am: Link against pthread for tests that use it

--

Compilation on CentOS 8 Stream failed without this.

Signed-off-by: Clemens Lang <cllang at redhat.com>
---
 configure.ac      | 1 +
 tests/Makefile.am | 5 +++++
 2 files changed, 6 insertions(+)

diff --git a/configure.ac b/configure.ac
index a9350c9c..9034194a 100644
--- a/configure.ac
+++ b/configure.ac
@@ -812,6 +812,7 @@ if test "$have_w32_system" != yes; then
     AC_DEFINE(HAVE_PTHREAD, 1 ,[Define if we have pthread.])
   fi
 fi
+AM_CONDITIONAL(HAVE_PTHREAD, test "$have_w32_system" != yes && test "$have_pthread" = yes)
 
 
 # Solaris needs -lsocket and -lnsl. Unisys system includes
diff --git a/tests/Makefile.am b/tests/Makefile.am
index e6953fd3..a4ad267f 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -98,6 +98,11 @@ t_kdf_LDADD = $(standard_ldadd) $(GPG_ERROR_MT_LIBS) @LDADD_FOR_TESTS_KLUDGE@
 t_kdf_CFLAGS = $(GPG_ERROR_MT_CFLAGS)
 endif
 
+if HAVE_PTHREAD
+t_lock_LDADD += -lpthread
+t_kdf_LDADD += -lpthread
+endif
+
 # xcheck uses our new testdrv instead of the automake test runner.
 .PHONY: xcheck xtestsuite
 xcheck: testdrv$(EXEEXT)
-- 
2.34.1




More information about the Gcrypt-devel mailing list