Although bitcoin/bitcoin#22646 was a great change, it broke Windows builds with DEBUG=1
:
0$ make -C depends HOST=x86_64-w64-mingw32 DEBUG=1 NO_QT=1 NO_ZMQ=1 NO_WALLET=1 NO_UPNP=1 NO_NATPMP=1
1$ ./autogen.sh
2$ ./configure CONFIG_SITE=$PWD/depends/x86_64-w64-mingw32/share/config.site --without-libs
3$ make clean
4$ make
5...
6 CXXLD bitcoind.exe
7/usr/bin/x86_64-w64-mingw32-ld: ./.libs/libunivalue.a(libunivalue_la-univalue.o):univalue.cpp:(.text+0x7d1): undefined reference to `__imp_pthread_mutex_lock'
8/usr/bin/x86_64-w64-mingw32-ld: ./.libs/libunivalue.a(libunivalue_la-univalue.o):univalue.cpp:(.text+0x7d8): undefined reference to `__imp_pthread_mutex_unlock'
9...
Please note that the --without-libs
configuration option, therefore, this bug differs from bitcoin/bitcoin#19772.
Unfortunately, this is another evidence of the tough relationship between Libtool and cross-compiler for MinGW-w64. Other workarounds see here and here.
This PR avoids using Libtool for the libunivalue
library at all. After bitcoin/bitcoin#22646 the libunivalue
library been built not using its own build system. In such a context it will never be a shared library. Therefore, no need to use Libtool, and the libunivalue
library could be a non-Libtool convenience library.
Btw, I strongly believe such an approach could also solve bitcoin/bitcoin#19772.
FWIW, while working on this PR I found a more concise fix:
0--- a/src/Makefile.univalue.include
1+++ b/src/Makefile.univalue.include
2@@ -4,3 +4,6 @@ LIBUNIVALUE = libunivalue.la
3 noinst_LTLIBRARIES += $(LIBUNIVALUE)
4 libunivalue_la_SOURCES = $(UNIVALUE_LIB_SOURCES_INT) $(UNIVALUE_DIST_HEADERS_INT) $(UNIVALUE_LIB_HEADERS_INT) $(UNIVALUE_TEST_FILES_INT)
5 libunivalue_la_CPPFLAGS = $(AM_CPPFLAGS) -I$(srcdir)/$(UNIVALUE_INCLUDE_DIR_INT)
6+if TARGET_WINDOWS
7+libunivalue_la_LDFLAGS = -static
8+endif