Skip to content

Commit 1ef1dbd

Browse files
committed
Fix mingw64 linking bugs
1 parent e2d2b0f commit 1ef1dbd

File tree

3 files changed

+17
-0
lines changed

3 files changed

+17
-0
lines changed

Makefile.am

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,13 +146,19 @@ ecdsa_example_SOURCES = examples/ecdsa.c
146146
ecdsa_example_CPPFLAGS = -I$(top_srcdir)/include
147147
ecdsa_example_LDADD = libsecp256k1.la
148148
ecdsa_example_LDFLAGS = -static
149+
if BUILD_WINDOWS
150+
ecdsa_example_LDFLAGS += -lbcrypt
151+
endif
149152
TESTS += ecdsa_example
150153
if ENABLE_MODULE_ECDH
151154
noinst_PROGRAMS += ecdh_example
152155
ecdh_example_SOURCES = examples/ecdh.c
153156
ecdh_example_CPPFLAGS = -I$(top_srcdir)/include
154157
ecdh_example_LDADD = libsecp256k1.la
155158
ecdh_example_LDFLAGS = -static
159+
if BUILD_WINDOWS
160+
ecdh_example_LDFLAGS += -lbcrypt
161+
endif
156162
TESTS += ecdh_example
157163
endif
158164
if ENABLE_MODULE_SCHNORRSIG
@@ -161,6 +167,9 @@ schnorr_example_SOURCES = examples/schnorr.c
161167
schnorr_example_CPPFLAGS = -I$(top_srcdir)/include
162168
schnorr_example_LDADD = libsecp256k1.la
163169
schnorr_example_LDFLAGS = -static
170+
if BUILD_WINDOWS
171+
schnorr_example_LDFLAGS += -lbcrypt
172+
endif
164173
TESTS += schnorr_example
165174
endif
166175
endif

configure.ac

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,8 @@ if test x"$ac_cv_prog_cc_c89" = x"no"; then
4545
fi
4646
AM_PROG_AS
4747

48+
build_windows=no
49+
4850
case $host_os in
4951
*darwin*)
5052
if test x$cross_compiling != xyes; then
@@ -68,6 +70,9 @@ case $host_os in
6870
fi
6971
fi
7072
;;
73+
cygwin*|mingw*)
74+
build_windows=yes
75+
;;
7176
esac
7277

7378
# Try if some desirable compiler flags are supported and append them to SECP_CFLAGS.
@@ -406,6 +411,7 @@ AM_CONDITIONAL([ENABLE_MODULE_EXTRAKEYS], [test x"$enable_module_extrakeys" = x"
406411
AM_CONDITIONAL([ENABLE_MODULE_SCHNORRSIG], [test x"$enable_module_schnorrsig" = x"yes"])
407412
AM_CONDITIONAL([USE_EXTERNAL_ASM], [test x"$use_external_asm" = x"yes"])
408413
AM_CONDITIONAL([USE_ASM_ARM], [test x"$set_asm" = x"arm"])
414+
AM_CONDITIONAL([BUILD_WINDOWS], [test "$build_windows" = "yes"])
409415
AC_SUBST(LIB_VERSION_CURRENT, _LIB_VERSION_CURRENT)
410416
AC_SUBST(LIB_VERSION_REVISION, _LIB_VERSION_REVISION)
411417
AC_SUBST(LIB_VERSION_AGE, _LIB_VERSION_AGE)

examples/random.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616
*/
1717

1818
#if defined(_WIN32)
19+
#include <windows.h>
20+
#include <ntstatus.h>
1921
#include <bcrypt.h>
2022
#elif defined(__linux__) || defined(__APPLE__) || defined(__FreeBSD__)
2123
#include <sys/random.h>

0 commit comments

Comments
 (0)