Using the following process we get a link error:
$ gnulib-tool --create-testdir --dir testdir1 \
`gnulib-tool --list | grep crypto/gc`
$ cd testdir1
$ ./configure && make
[...]
gcc -Wno-error -Wno-error -g -O2 -o test-gc-arctwo test-gc-arctwo.o
libtests.a ../gllib/libgnu.a libtests.a ../gllib/libgnu.a libtests.a
/usr/bin/ld: ../gllib/libgnu.a(gc-gnulib.o): in function `md5_init_ctx':
/home/collin/.local/src/gnulib/testdir1/gllib/gl_openssl.h:81:(.text+0x7dd):
undefined reference to `MD5_Init'
/usr/bin/ld: ../gllib/libgnu.a(gc-gnulib.o): in function `sha1_init_ctx':
/home/collin/.local/src/gnulib/testdir1/gllib/gl_openssl.h:81:(.text+0x7fd):
undefined reference to `SHA1_Init'
/usr/bin/ld: ../gllib/libgnu.a(gc-gnulib.o): in function `sha256_init_ctx':
[...]
This is because $(LIB_CRYPTO) may be required for the gc module used by
gc-arctwo if other gc-* modules are in use, even though gc-arctwo does
not use it directly.
I pushed this patch to fix the link error and add a 'Link:' directive to
the gc module so gnulib tool emits the hint on importing.
Collin
>From 4e77b6d1fec55a21c7421c80f3d5a890973ea889 Mon Sep 17 00:00:00 2001
Message-ID: <4e77b6d1fec55a21c7421c80f3d5a890973ea889.1758601673.git.collin.fu...@gmail.com>
From: Collin Funk <[email protected]>
Date: Mon, 22 Sep 2025 21:27:13 -0700
Subject: [PATCH] crypto/gc-arctwo-tests: Fix link error when OpenSSL is
enabled.
* modules/crypto/gc (Link): Add $(LIB_CRYPTO).
* modules/crypto/gc-arctwo-tests (Makefile.am): Link the test program to
@LIB_CRYPTO@.
---
ChangeLog | 7 +++++++
modules/crypto/gc | 3 +++
modules/crypto/gc-arctwo-tests | 2 +-
3 files changed, 11 insertions(+), 1 deletion(-)
diff --git a/ChangeLog b/ChangeLog
index 24f2d90e87..adf086501a 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2025-09-22 Collin Funk <[email protected]>
+
+ crypto/gc-arctwo-tests: Fix link error when OpenSSL is enabled.
+ * modules/crypto/gc (Link): Add $(LIB_CRYPTO).
+ * modules/crypto/gc-arctwo-tests (Makefile.am): Link the test program to
+ @LIB_CRYPTO@.
+
2025-09-22 Bruno Haible <[email protected]>
fchownat: Revert my earlier change today entirely.
diff --git a/modules/crypto/gc b/modules/crypto/gc
index bda331ff3d..385b9e3977 100644
--- a/modules/crypto/gc
+++ b/modules/crypto/gc
@@ -31,6 +31,9 @@ lib_LDFLAGS += $(LTLIBGCRYPT)
Include:
"gc.h"
+Link:
+$(LIB_CRYPTO)
+
License:
LGPLv2+
diff --git a/modules/crypto/gc-arctwo-tests b/modules/crypto/gc-arctwo-tests
index 8bd22cc0e6..7771351b6e 100644
--- a/modules/crypto/gc-arctwo-tests
+++ b/modules/crypto/gc-arctwo-tests
@@ -8,4 +8,4 @@ configure.ac:
Makefile.am:
TESTS += test-gc-arctwo
check_PROGRAMS += test-gc-arctwo
-test_gc_arctwo_LDADD = $(LDADD) $(GETRANDOM_LIB)
+test_gc_arctwo_LDADD = $(LDADD) @LIB_CRYPTO@ $(GETRANDOM_LIB)
--
2.51.0