* crypto/gc-random: Fix link error on MSVC
@ 2020-05-30 12:16 Bruno Haible
2020-05-30 12:26 ` Jeffrey Walton
0 siblings, 1 reply; 2+ messages in thread
From: Bruno Haible @ 2020-05-30 12:16 UTC (permalink / raw)
To: bug-gnulib
A testdir for module 'crypto/gc-random' produces a link error
on MSVC 14:
libgnu.a(gc-gnulib.obj) : error LNK2019: unresolved external symbol __imp_CryptAcquireContextA referenced in function gc_init
libgnu.a(gc-gnulib.obj) : error LNK2019: unresolved external symbol __imp_CryptReleaseContext referenced in function gc_init
libgnu.a(gc-gnulib.obj) : error LNK2019: unresolved external symbol __imp_CryptGenRandom referenced in function randomize
test-gc.exe : fatal error LNK1120: 3 unresolved externals
This patch fixes it.
2020-05-30 Bruno Haible <bruno@clisp.org>
crypto/gc-random: Fix link error on MSVC.
* m4/gc-random.m4 (gl_GC_RANDOM): Set LIB_GC_RANDOM.
* modules/crypto/gc-random (Link): New section.
* modules/crypto/gc-tests (Makefile.am): Link test-gc against
$(LIB_GC_RANDOM).
diff --git a/m4/gc-random.m4 b/m4/gc-random.m4
index 09483da..de9c1bb 100644
--- a/m4/gc-random.m4
+++ b/m4/gc-random.m4
@@ -1,4 +1,4 @@
-# gc-random.m4 serial 6
+# gc-random.m4 serial 7
dnl Copyright (C) 2005-2020 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it,
@@ -9,7 +9,7 @@ AC_DEFUN([gl_GC_RANDOM],
# Devices with randomness.
# FIXME: Are these the best defaults?
- AC_REQUIRE([AC_CANONICAL_HOST])dnl
+ AC_REQUIRE([AC_CANONICAL_HOST])
case "$host_os" in
*openbsd* | *mirbsd*)
@@ -84,4 +84,12 @@ AC_DEFUN([gl_GC_RANDOM],
[defined to the name of the pseudo random device])
AC_DEFINE_UNQUOTED([NAME_OF_NONCE_DEVICE], ["$NAME_OF_NONCE_DEVICE"],
[defined to the name of the unpredictable nonce device])
+
+ case $host_os in
+ mingw*)
+ LIB_GC_RANDOM='-ladvapi32' ;;
+ *)
+ LIB_GC_RANDOM= ;;
+ esac
+ AC_SUBST([LIB_GC_RANDOM])
])
diff --git a/modules/crypto/gc-random b/modules/crypto/gc-random
index 2f17871..2ffec7c 100644
--- a/modules/crypto/gc-random
+++ b/modules/crypto/gc-random
@@ -16,6 +16,9 @@ Makefile.am:
Include:
"gc.h"
+Link:
+$(LIB_GC_RANDOM)
+
License:
LGPLv2+
diff --git a/modules/crypto/gc-tests b/modules/crypto/gc-tests
index 7b153d1..f3da986 100644
--- a/modules/crypto/gc-tests
+++ b/modules/crypto/gc-tests
@@ -8,4 +8,4 @@ configure.ac:
Makefile.am:
TESTS += test-gc
check_PROGRAMS += test-gc
-test_gc_LDADD = $(LDADD) @LIB_CRYPTO@
+test_gc_LDADD = $(LDADD) @LIB_CRYPTO@ $(LIB_GC_RANDOM)
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: crypto/gc-random: Fix link error on MSVC
2020-05-30 12:16 crypto/gc-random: Fix link error on MSVC Bruno Haible
@ 2020-05-30 12:26 ` Jeffrey Walton
0 siblings, 0 replies; 2+ messages in thread
From: Jeffrey Walton @ 2020-05-30 12:26 UTC (permalink / raw)
To: Bruno Haible; +Cc: bug-gnulib
On Sat, May 30, 2020 at 8:17 AM Bruno Haible <bruno@clisp.org> wrote:
>
> A testdir for module 'crypto/gc-random' produces a link error
> on MSVC 14:
>
> libgnu.a(gc-gnulib.obj) : error LNK2019: unresolved external symbol __imp_CryptAcquireContextA referenced in function gc_init
> libgnu.a(gc-gnulib.obj) : error LNK2019: unresolved external symbol __imp_CryptReleaseContext referenced in function gc_init
> libgnu.a(gc-gnulib.obj) : error LNK2019: unresolved external symbol __imp_CryptGenRandom referenced in function randomize
> test-gc.exe : fatal error LNK1120: 3 unresolved externals
>
> This patch fixes it.
>
>
> 2020-05-30 Bruno Haible <bruno@clisp.org>
>
> crypto/gc-random: Fix link error on MSVC.
> * m4/gc-random.m4 (gl_GC_RANDOM): Set LIB_GC_RANDOM.
> * modules/crypto/gc-random (Link): New section.
> * modules/crypto/gc-tests (Makefile.am): Link test-gc against
> $(LIB_GC_RANDOM).
>
> diff --git a/m4/gc-random.m4 b/m4/gc-random.m4
> index 09483da..de9c1bb 100644
> --- a/m4/gc-random.m4
> +++ b/m4/gc-random.m4
> @@ -1,4 +1,4 @@
> -# gc-random.m4 serial 6
> +# gc-random.m4 serial 7
> dnl Copyright (C) 2005-2020 Free Software Foundation, Inc.
> dnl This file is free software; the Free Software Foundation
> dnl gives unlimited permission to copy and/or distribute it,
> @@ -9,7 +9,7 @@ AC_DEFUN([gl_GC_RANDOM],
> # Devices with randomness.
> # FIXME: Are these the best defaults?
>
> - AC_REQUIRE([AC_CANONICAL_HOST])dnl
> + AC_REQUIRE([AC_CANONICAL_HOST])
>
> case "$host_os" in
> *openbsd* | *mirbsd*)
> @@ -84,4 +84,12 @@ AC_DEFUN([gl_GC_RANDOM],
> [defined to the name of the pseudo random device])
> AC_DEFINE_UNQUOTED([NAME_OF_NONCE_DEVICE], ["$NAME_OF_NONCE_DEVICE"],
> [defined to the name of the unpredictable nonce device])
> +
> + case $host_os in
> + mingw*)
> + LIB_GC_RANDOM='-ladvapi32' ;;
> + *)
> + LIB_GC_RANDOM= ;;
> + esac
> + AC_SUBST([LIB_GC_RANDOM])
> ])
> diff --git a/modules/crypto/gc-random b/modules/crypto/gc-random
> index 2f17871..2ffec7c 100644
> --- a/modules/crypto/gc-random
> +++ b/modules/crypto/gc-random
> @@ -16,6 +16,9 @@ Makefile.am:
> Include:
> "gc.h"
>
> +Link:
> +$(LIB_GC_RANDOM)
> +
> License:
> LGPLv2+
>
> diff --git a/modules/crypto/gc-tests b/modules/crypto/gc-tests
> index 7b153d1..f3da986 100644
> --- a/modules/crypto/gc-tests
> +++ b/modules/crypto/gc-tests
> @@ -8,4 +8,4 @@ configure.ac:
> Makefile.am:
> TESTS += test-gc
> check_PROGRAMS += test-gc
> -test_gc_LDADD = $(LDADD) @LIB_CRYPTO@
> +test_gc_LDADD = $(LDADD) @LIB_CRYPTO@ $(LIB_GC_RANDOM)
On modern Windows systems you should use BCryptGenRandom for the
material. CryptGenRandom is deprecated.
Also see https://docs.microsoft.com/en-us/windows/win32/api/wincrypt/nf-wincrypt-cryptgenrandom.
Jeff
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2020-05-30 12:26 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-05-30 12:16 crypto/gc-random: Fix link error on MSVC Bruno Haible
2020-05-30 12:26 ` Jeffrey Walton
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).