bug-gnulib
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Fix various test link errors on MSVC


From: Bruno Haible
Subject: Fix various test link errors on MSVC
Date: Mon, 05 Sep 2022 03:34:51 +0200

In MSVC builds, I get some link errors. Such as

in 32-bit mode:

/home/bruno/msvc/compile cl -nologo  -MD  -L/usr/local/msvc32/lib -o 
test-gc-des.exe test-gc-des.obj libtests.a ../gllib/libgnu.a libtests.a 
../gllib/libgnu.a libtests.a   
libgnu.a(getrandom.obj) : error LNK2019: unresolved external symbol 
__imp__CryptAcquireContextA@20 referenced in function _getrandom
libgnu.a(getrandom.obj) : error LNK2019: unresolved external symbol 
__imp__CryptGenRandom@12 referenced in function _getrandom
test-gc-des.exe : fatal error LNK1120: 2 unresolved externals
make[4]: *** [Makefile:17289: test-gc-des.exe] Error 2

in 64-bit mode:

/home/bruno/msvc/compile cl -nologo  -MD  -L/usr/local/msvc64/lib -o 
test-gc-des.exe test-gc-des.obj libtests.a ../gllib/libgnu.a libtests.a 
../gllib/libgnu.a libtests.a
libgnu.a(getrandom.obj) : error LNK2019: unresolved external symbol 
BCryptGenRandom referenced in function getrandom
test-gc-des.exe : fatal error LNK1120: 1 unresolved externals
make[4]: *** [Makefile:17289: test-gc-des.exe] Error 2

The fix is to link these programs with $(LIB_GETRANDOM).


2022-09-04  Bruno Haible  <bruno@clisp.org>

        Fix various test link errors on MSVC.
        * modules/crypto/gc-arcfour-tests (Makefile.am): Link test-gc-arcfour
        with $(LIB_GETRANDOM).
        * modules/crypto/gc-arctwo-tests (Makefile.am): Link test-gc-arctwo with
        $(LIB_GETRANDOM).
        * modules/crypto/gc-des-tests (Makefile.am): Link test-gc-des with
        $(LIB_GETRANDOM).
        * modules/crypto/gc-hmac-md5-tests (Makefile.am): Link test-gc-hmac-md5
        with $(LIB_GETRANDOM).
        * modules/crypto/gc-hmac-sha1-tests (Makefile.am): Link
        test-gc-hmac-sha1 with $(LIB_GETRANDOM).
        * modules/crypto/gc-hmac-sha256-tests (Makefile.am): Link
        test-gc-hmac-sha256 with $(LIB_GETRANDOM).
        * modules/crypto/gc-hmac-sha512-tests (Makefile.am): Link
        test-gc-hmac-sha512 with $(LIB_GETRANDOM).
        * modules/crypto/gc-md2-tests (Makefile.am): Link test-gc-md2 with
        $(LIB_GETRANDOM).
        * modules/crypto/gc-md4-tests (Makefile.am): Link test-gc-md4 with
        $(LIB_GETRANDOM).
        * modules/crypto/gc-md5-tests (Makefile.am): Link test-gc-md5 with
        $(LIB_GETRANDOM).
        * modules/crypto/gc-pbkdf2-tests (Makefile.am): Link test-gc-pbkdf2 with
        $(LIB_GETRANDOM).
        * modules/crypto/gc-pbkdf2-sha1-tests (Makefile.am): Link
        test-gc-pbkdf2-sha1 with $(LIB_GETRANDOM).
        * modules/crypto/gc-rijndael-tests (Makefile.am): Link test-gc-rijndael
        with $(LIB_GETRANDOM).
        * modules/crypto/gc-sha1-tests (Makefile.am): Link test-gc-sha1 with
        $(LIB_GETRANDOM).
        * modules/crypto/gc-sha256-tests (Makefile.am): Link test-gc-sha256 with
        $(LIB_GETRANDOM).
        * modules/crypto/gc-sha512-tests (Makefile.am): Link test-gc-sha512 with
        $(LIB_GETRANDOM).
        * modules/crypto/gc-sm3-tests (Makefile.am): Link test-gc-sm3 with
        $(LIB_GETRANDOM).
        * modules/sys_stat-c++-tests (Makefile.am): Link test-sys_stat-c++ with
        $(LIB_GETRANDOM).
        * modules/unistd-c++-tests (Makefile.am): Link test-unistd-c++ with
        $(LIB_GETRANDOM).

diff --git a/modules/crypto/gc-arcfour-tests b/modules/crypto/gc-arcfour-tests
index b0ed0bd694..c6ebcb663f 100644
--- a/modules/crypto/gc-arcfour-tests
+++ b/modules/crypto/gc-arcfour-tests
@@ -8,3 +8,4 @@ configure.ac:
 Makefile.am:
 TESTS += test-gc-arcfour
 check_PROGRAMS += test-gc-arcfour
+test_gc_arcfour_LDADD = $(LDADD) $(LIB_GETRANDOM)
diff --git a/modules/crypto/gc-arctwo-tests b/modules/crypto/gc-arctwo-tests
index d1cdaff991..6e74c80c2f 100644
--- a/modules/crypto/gc-arctwo-tests
+++ b/modules/crypto/gc-arctwo-tests
@@ -8,3 +8,4 @@ configure.ac:
 Makefile.am:
 TESTS += test-gc-arctwo
 check_PROGRAMS += test-gc-arctwo
+test_gc_arctwo_LDADD = $(LDADD) $(LIB_GETRANDOM)
diff --git a/modules/crypto/gc-des-tests b/modules/crypto/gc-des-tests
index a041a1c419..5d1bd46ee8 100644
--- a/modules/crypto/gc-des-tests
+++ b/modules/crypto/gc-des-tests
@@ -8,4 +8,4 @@ configure.ac:
 Makefile.am:
 TESTS += test-gc-des
 check_PROGRAMS += test-gc-des
-test_gc_des_LDADD = $(LDADD) @LIB_CRYPTO@
+test_gc_des_LDADD = $(LDADD) @LIB_CRYPTO@ $(LIB_GETRANDOM)
diff --git a/modules/crypto/gc-hmac-md5-tests b/modules/crypto/gc-hmac-md5-tests
index 7ae3d2f79d..345ba872ac 100644
--- a/modules/crypto/gc-hmac-md5-tests
+++ b/modules/crypto/gc-hmac-md5-tests
@@ -8,4 +8,4 @@ configure.ac:
 Makefile.am:
 TESTS += test-gc-hmac-md5
 check_PROGRAMS += test-gc-hmac-md5
-test_gc_hmac_md5_LDADD = $(LDADD) @LIB_CRYPTO@
+test_gc_hmac_md5_LDADD = $(LDADD) @LIB_CRYPTO@ $(LIB_GETRANDOM)
diff --git a/modules/crypto/gc-hmac-sha1-tests 
b/modules/crypto/gc-hmac-sha1-tests
index 9cc23aea27..c1effd7864 100644
--- a/modules/crypto/gc-hmac-sha1-tests
+++ b/modules/crypto/gc-hmac-sha1-tests
@@ -8,4 +8,4 @@ configure.ac:
 Makefile.am:
 TESTS += test-gc-hmac-sha1
 check_PROGRAMS += test-gc-hmac-sha1
-test_gc_hmac_sha1_LDADD = $(LDADD) @LIB_CRYPTO@
+test_gc_hmac_sha1_LDADD = $(LDADD) @LIB_CRYPTO@ $(LIB_GETRANDOM)
diff --git a/modules/crypto/gc-hmac-sha256-tests 
b/modules/crypto/gc-hmac-sha256-tests
index 82f0b44ba2..de0370fe09 100644
--- a/modules/crypto/gc-hmac-sha256-tests
+++ b/modules/crypto/gc-hmac-sha256-tests
@@ -8,4 +8,4 @@ configure.ac:
 Makefile.am:
 TESTS += test-gc-hmac-sha256
 check_PROGRAMS += test-gc-hmac-sha256
-test_gc_hmac_sha256_LDADD = $(LDADD) @LIB_CRYPTO@
+test_gc_hmac_sha256_LDADD = $(LDADD) @LIB_CRYPTO@ $(LIB_GETRANDOM)
diff --git a/modules/crypto/gc-hmac-sha512-tests 
b/modules/crypto/gc-hmac-sha512-tests
index e308f986c0..e1c2e478f0 100644
--- a/modules/crypto/gc-hmac-sha512-tests
+++ b/modules/crypto/gc-hmac-sha512-tests
@@ -8,4 +8,4 @@ configure.ac:
 Makefile.am:
 TESTS += test-gc-hmac-sha512
 check_PROGRAMS += test-gc-hmac-sha512
-test_gc_hmac_sha512_LDADD = $(LDADD) @LIB_CRYPTO@
+test_gc_hmac_sha512_LDADD = $(LDADD) @LIB_CRYPTO@ $(LIB_GETRANDOM)
diff --git a/modules/crypto/gc-md2-tests b/modules/crypto/gc-md2-tests
index 74ccdf03cd..b7ef11ff7c 100644
--- a/modules/crypto/gc-md2-tests
+++ b/modules/crypto/gc-md2-tests
@@ -8,4 +8,4 @@ configure.ac:
 Makefile.am:
 TESTS += test-gc-md2
 check_PROGRAMS += test-gc-md2
-test_gc_md2_LDADD = $(LDADD) @LIB_CRYPTO@
+test_gc_md2_LDADD = $(LDADD) @LIB_CRYPTO@ $(LIB_GETRANDOM)
diff --git a/modules/crypto/gc-md4-tests b/modules/crypto/gc-md4-tests
index b2a4ce1a12..0b32e7e52f 100644
--- a/modules/crypto/gc-md4-tests
+++ b/modules/crypto/gc-md4-tests
@@ -8,4 +8,4 @@ configure.ac:
 Makefile.am:
 TESTS += test-gc-md4
 check_PROGRAMS += test-gc-md4
-test_gc_md4_LDADD = $(LDADD) @LIB_CRYPTO@
+test_gc_md4_LDADD = $(LDADD) @LIB_CRYPTO@ $(LIB_GETRANDOM)
diff --git a/modules/crypto/gc-md5-tests b/modules/crypto/gc-md5-tests
index 865e77e659..4e4b8f8023 100644
--- a/modules/crypto/gc-md5-tests
+++ b/modules/crypto/gc-md5-tests
@@ -8,4 +8,4 @@ configure.ac:
 Makefile.am:
 TESTS += test-gc-md5
 check_PROGRAMS += test-gc-md5
-test_gc_md5_LDADD = $(LDADD) @LIB_CRYPTO@
+test_gc_md5_LDADD = $(LDADD) @LIB_CRYPTO@ $(LIB_GETRANDOM)
diff --git a/modules/crypto/gc-pbkdf2-sha1-tests 
b/modules/crypto/gc-pbkdf2-sha1-tests
index d88b541701..b1d73c785e 100644
--- a/modules/crypto/gc-pbkdf2-sha1-tests
+++ b/modules/crypto/gc-pbkdf2-sha1-tests
@@ -8,4 +8,4 @@ configure.ac:
 Makefile.am:
 TESTS += test-gc-pbkdf2-sha1
 check_PROGRAMS += test-gc-pbkdf2-sha1
-test_gc_pbkdf2_sha1_LDADD = $(LDADD) @LIB_CRYPTO@
+test_gc_pbkdf2_sha1_LDADD = $(LDADD) @LIB_CRYPTO@ $(LIB_GETRANDOM)
diff --git a/modules/crypto/gc-pbkdf2-tests b/modules/crypto/gc-pbkdf2-tests
index 0b90547c78..f5eac92289 100644
--- a/modules/crypto/gc-pbkdf2-tests
+++ b/modules/crypto/gc-pbkdf2-tests
@@ -8,4 +8,4 @@ configure.ac:
 Makefile.am:
 TESTS += test-gc-pbkdf2
 check_PROGRAMS += test-gc-pbkdf2
-test_gc_pbkdf2_LDADD = $(LDADD) @LIB_CRYPTO@
+test_gc_pbkdf2_LDADD = $(LDADD) @LIB_CRYPTO@ $(LIB_GETRANDOM)
diff --git a/modules/crypto/gc-rijndael-tests b/modules/crypto/gc-rijndael-tests
index c7aaee2d63..7c87920df6 100644
--- a/modules/crypto/gc-rijndael-tests
+++ b/modules/crypto/gc-rijndael-tests
@@ -8,4 +8,4 @@ configure.ac:
 Makefile.am:
 TESTS += test-gc-rijndael
 check_PROGRAMS += test-gc-rijndael
-test_gc_rijndael_LDADD = $(LDADD) @LIB_CRYPTO@
+test_gc_rijndael_LDADD = $(LDADD) @LIB_CRYPTO@ $(LIB_GETRANDOM)
diff --git a/modules/crypto/gc-sha1-tests b/modules/crypto/gc-sha1-tests
index 7cfef60da6..afa1ba2f35 100644
--- a/modules/crypto/gc-sha1-tests
+++ b/modules/crypto/gc-sha1-tests
@@ -8,4 +8,4 @@ configure.ac:
 Makefile.am:
 TESTS += test-gc-sha1
 check_PROGRAMS += test-gc-sha1
-test_gc_sha1_LDADD = $(LDADD) @LIB_CRYPTO@
+test_gc_sha1_LDADD = $(LDADD) @LIB_CRYPTO@ $(LIB_GETRANDOM)
diff --git a/modules/crypto/gc-sha256-tests b/modules/crypto/gc-sha256-tests
index 677ed62da0..13c55c5930 100644
--- a/modules/crypto/gc-sha256-tests
+++ b/modules/crypto/gc-sha256-tests
@@ -8,4 +8,4 @@ configure.ac:
 Makefile.am:
 TESTS += test-gc-sha256
 check_PROGRAMS += test-gc-sha256
-test_gc_sha256_LDADD = $(LDADD) @LIB_CRYPTO@
+test_gc_sha256_LDADD = $(LDADD) @LIB_CRYPTO@ $(LIB_GETRANDOM)
diff --git a/modules/crypto/gc-sha512-tests b/modules/crypto/gc-sha512-tests
index b007cd108e..22cb3bab4c 100644
--- a/modules/crypto/gc-sha512-tests
+++ b/modules/crypto/gc-sha512-tests
@@ -8,4 +8,4 @@ configure.ac:
 Makefile.am:
 TESTS += test-gc-sha512
 check_PROGRAMS += test-gc-sha512
-test_gc_sha512_LDADD = $(LDADD) @LIB_CRYPTO@
+test_gc_sha512_LDADD = $(LDADD) @LIB_CRYPTO@ $(LIB_GETRANDOM)
diff --git a/modules/crypto/gc-sm3-tests b/modules/crypto/gc-sm3-tests
index 006f41f374..f64322a6d9 100644
--- a/modules/crypto/gc-sm3-tests
+++ b/modules/crypto/gc-sm3-tests
@@ -8,4 +8,4 @@ configure.ac:
 Makefile.am:
 TESTS += test-gc-sm3
 check_PROGRAMS += test-gc-sm3
-test_gc_sm3_LDADD = $(LDADD) @LIB_CRYPTO@
+test_gc_sm3_LDADD = $(LDADD) @LIB_CRYPTO@ $(LIB_GETRANDOM)
diff --git a/modules/sys_stat-c++-tests b/modules/sys_stat-c++-tests
index 576ef07014..3a612151b4 100644
--- a/modules/sys_stat-c++-tests
+++ b/modules/sys_stat-c++-tests
@@ -15,5 +15,5 @@ if ANSICXX
 TESTS += test-sys_stat-c++
 check_PROGRAMS += test-sys_stat-c++
 test_sys_stat_c___SOURCES = test-sys_stat-c++.cc
-test_sys_stat_c___LDADD = $(LDADD) $(LIBINTL) $(LIB_CLOCK_GETTIME) 
$(LIB_MBRTOWC)
+test_sys_stat_c___LDADD = $(LDADD) $(LIBINTL) $(LIB_CLOCK_GETTIME) 
$(LIB_MBRTOWC) $(LIB_GETRANDOM)
 endif
diff --git a/modules/unistd-c++-tests b/modules/unistd-c++-tests
index 739382b562..3aaf52bbe7 100644
--- a/modules/unistd-c++-tests
+++ b/modules/unistd-c++-tests
@@ -15,5 +15,5 @@ if ANSICXX
 TESTS += test-unistd-c++
 check_PROGRAMS += test-unistd-c++
 test_unistd_c___SOURCES = test-unistd-c++.cc
-test_unistd_c___LDADD = $(LDADD) $(LIBINTL) $(LIB_CLOCK_GETTIME) 
$(LIB_EACCESS) $(LIBSOCKET) $(LIB_GETLOGIN)
+test_unistd_c___LDADD = $(LDADD) $(LIBINTL) $(LIB_CLOCK_GETTIME) 
$(LIB_EACCESS) $(LIBSOCKET) $(LIB_GETLOGIN) $(LIB_GETRANDOM)
 endif






reply via email to

[Prev in Thread] Current Thread [Next in Thread]