From 99c943bbf52ba7930b3b7004d4a136cc2d22e10d Mon Sep 17 00:00:00 2001
From: Orgad Shaneh <orgads@gmail.com>
Date: Sun, 15 Nov 2020 12:20:32 +0200
Subject: [PATCH] Fix link order on Windows

libgnu uses ntop, which comes from ws2_32 library, so ws2_32 needs
to be linked after libgnu. It also uses bcrypt, so link that too.
---
 gdb/Makefile.in | 2 +-
 gdb/configure   | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/gdb/Makefile.in b/gdb/Makefile.in
index 4808357e65..0da79ab040 100644
--- a/gdb/Makefile.in
+++ b/gdb/Makefile.in
@@ -626,7 +626,7 @@ CLIBS = $(SIM) $(READLINE) $(OPCODES) $(LIBCTF) $(BFD) $(ZLIB) \
 	$(XM_CLIBS) $(GDBTKLIBS) \
 	@LIBS@ @GUILE_LIBS@ @PYTHON_LIBS@ \
 	$(LIBEXPAT) $(LIBLZMA) $(LIBBABELTRACE) $(LIBIPT) \
-	$(WIN32LIBS) $(LIBGNU) $(LIBICONV) \
+	$(LIBGNU) $(WIN32LIBS) $(LIBICONV) \
 	$(LIBMPFR) $(SRCHIGH_LIBS) $(LIBXXHASH) $(PTHREAD_LIBS) \
 	$(DEBUGINFOD_LIBS)
 CDEPS = $(NAT_CDEPS) $(SIM) $(BFD) $(READLINE_DEPS) $(CTF_DEPS) \
diff --git a/gdb/configure b/gdb/configure
index e7811e807a..1c178eb74d 100755
--- a/gdb/configure
+++ b/gdb/configure
@@ -12998,7 +12998,7 @@ fi
 
 $as_echo "#define USE_WIN32API 1" >>confdefs.h
 
-      WIN32APILIBS="-lws2_32"
+      WIN32APILIBS="-lws2_32 -lbcrypt"
       ;;
   esac
 
-- 
2.29.2.windows.1

