Repository: bitcoin/bitcoin (language: cpp)

Issue:
build: Cross-compiling libbitcoinconsensus for Windows fails with DEBUG=1
```
$ make -C depends HOST=x86_64-w64-mingw32 DEBUG=1 NO_QT=1 NO_QR=1 NO_ZMQ=1 NO_WALLET=1 NO_UPNP=1
$ ./autogen.sh 
$ CONFIG_SITE=$PWD/depends/x86_64-w64-mingw32/share/config.site ./configure --disable-wallet --disable-tests --disable-bench --without-utils --without-daemon --without-gui
$ make
Making all in src
make[1]: Entering directory '/home/hebasto/guix/GitHub/bitcoin/src'
make[2]: Entering directory '/home/hebasto/guix/GitHub/bitcoin/src'
  CXX      support/libbitcoinconsensus_la-cleanse.lo
  CXX      crypto/libbitcoinconsensus_la-aes.lo
  CXX      crypto/libbitcoinconsensus_la-chacha_poly_aead.lo
make[3]: Entering directory '/home/hebasto/guix/GitHub/bitcoin'
make[3]: Leaving directory '/home/hebasto/guix/GitHub/bitcoin'
  CXX      crypto/libbitcoinconsensus_la-hkdf_sha256_32.lo
  CXX      crypto/libbitcoinconsensus_la-hmac_sha256.lo
  CXX      crypto/libbitcoinconsensus_la-hmac_sha512.lo
  CXX      crypto/libbitcoinconsensus_la-poly1305.lo
  CXX      crypto/libbitcoinconsensus_la-ripemd160.lo
  CXX      crypto/libbitcoinconsensus_la-sha1.lo
  CXX      crypto/libbitcoinconsensus_la-sha256.lo
  CXX      crypto/libbitcoinconsensus_la-sha512.lo
  CXX      crypto/libbitcoinconsensus_la-siphash.lo
  CXX      crypto/libbitcoinconsensus_la-sha256_sse4.lo
  CXX      libbitcoinconsensus_la-arith_uint256.lo
  CXX      consensus/libbitcoinconsensus_la-merkle.lo
  CXX      consensus/libbitcoinconsensus_la-tx_check.lo
  CXX      libbitcoinconsensus_la-hash.lo
  CXX      primitives/libbitcoinconsensus_la-block.lo
  CXX      primitives/libbitcoinconsensus_la-transaction.lo
  CXX      libbitcoinconsensus_la-pubkey.lo
  CXX      script/libbitcoinconsensus_la-bitcoinconsensus.lo
  CXX      script/libbitcoinconsensus_la-interpreter.lo
  CXX      script/libbitcoinconsensus_la-script.lo
  CXX      script/libbitcoinconsensus_la-script_error.lo
  CXX      libbitcoinconsensus_la-uint256.lo
  CXX      util/libbitcoinconsensus_la-strencodings.lo
make[3]: Entering directory '/home/hebasto/guix/GitHub/bitcoin/src/secp256k1'
gcc -I. -I./src -Wall -Wextra -Wno-unused-function -g -O2 -c src/gen_context.c -o gen_context.o
  CXX      crypto/libbitcoinconsensus_la-chacha20.lo
gcc -Wall -Wextra -Wno-unused-function -g -O2  gen_context.o -o gen_context
./gen_context
  CC       src/libsecp256k1_la-secp256k1.lo
  CCLD     libsecp256k1.la
libtool: warning: undefined symbols not allowed in x86_64-w64-mingw32 shared libraries; building static only
make[3]: Leaving directory '/home/hebasto/guix/GitHub/bitcoin/src/secp256k1'
  CXXLD    libbitcoinconsensus.la
/usr/bin/x86_64-w64-mingw32-ld: consensus/.libs/libbitcoinconsensus_la-merkle.o:merkle.cpp:(.text$_ZN11__gnu_debug14_Safe_sequenceINSt7__debug6vectorI7uint256SaIS3_EEEE16_M_invalidate_ifINS_15_After_nth_fromIN9__gnu_cxx17__normal_iteratorIPKS3_NSt9__cxx19986vectorIS3_S4_EEEEEEEEvT_[_ZN11__gnu_debug14_Safe_sequenceINSt7__debug6vectorI7uint256SaIS3_EEEE16_M_invalidate_ifINS_15_After_nth_fromIN9__gnu_cxx17__normal_iteratorIPKS3_NSt9__cxx19986vectorIS3_S4_EEEEEEEEvT_]+0x34): undefined reference to `__imp_pthread_mutex_lock'
/usr/bin/x86_64-w64-mingw32-ld: consensus/.libs/libbitcoinconsensus_la-merkle.o:merkle.cpp:(.text$_ZN11__gnu_debug14_Safe_sequenceINSt7__debug6vectorI7uint256SaIS3_EEEE16_M_invalidate_ifINS_15_After_nth_fromIN9__gnu_cxx17__normal_iteratorIPKS3_NSt9__cxx19986vectorIS3_S4_EEEEEEEEvT_[_ZN11__gnu_debug14_Safe_sequenceINSt7__debug6vectorI7uint256SaIS3_EEEE16_M_invalidate_ifINS_15_After_nth_fromIN9__gnu_cxx17__normal_iteratorIPKS3_NSt9__cxx19986vectorIS3_S4_EEEEEEEEvT_]+0x53): undefined reference to `__imp_pthread_mutex_unlock'
/usr/bin/x86_64-w64-mingw32-ld: consensus/.libs/libbitcoinconsensus_la-tx_check.o:tx_check.cpp:(.text+0x44d): undefined reference to `__imp_pthread_mutex_lock'
/usr/bin/x86_64-w64-mingw32-ld: consensus/.libs/libbitcoinconsensus_la-tx_check.o:tx_check.cpp:(.text+0x464): undefined reference to `__imp_pthread_mutex_unlock'
/usr/bin/x86_64-w64-mingw32-ld: consensus/.libs/libbitcoinconsensus_la-tx_check.o:tx_check.cpp:(.text+0x1189): undefined reference to `__imp_pthread_mutex_lock'
/usr/bin/x86_64-w64-mingw32-ld: consensus/.libs/libbitcoinconsensus_la-tx_check.o:tx_check.cpp:(.text+0x11a6): undefined reference to `__imp_pthread_mutex_unlock'
/usr/bin/x86_64-w64-mingw32-ld: consensus/.libs/libbitcoinconsensus_la-tx_check.o:tx_check.cpp:(.text+0x179a): undefined reference to `__imp_pthread_mutex_lock'
/usr/bin/x86_64-w64-mingw32-ld: consensus/.libs/libbitcoinconsensus_la-tx_check.o:tx_check.cpp:(.text+0x17a1): undefined reference to `__imp_pthread_mutex_unlock'
/usr/bin/x86_64-w64-mingw32-ld: consensus/.libs/libbitcoinconsensus_la-tx_check.o:tx_check.cpp:(.text$_Z14Serialize_implI13CSizeComputerNSt7__debug6vectorIhSaIhEEESaIS4_ES4_EvRT_RKNS2_IT0_T1_EERKT2_[_Z14Serialize_implI13CSizeComputerNSt7__debug6vectorIhSaIhEEESaIS4_ES4_EvRT_RKNS2_IT0_T1_EERKT2_]+0x200): undefined reference to `__imp_pthread_mutex_lock'
/usr/bin/x86_64-w64-mingw32-ld: consensus/.libs/libbitcoinconsensus_la-tx_check.o:tx_check.cpp:(.text$_Z14Serialize_implI13CSizeComputerNSt7__debug6vectorIhSaIhEEESaIS4_ES4_EvRT_RKNS2_IT0_T1_EERKT2_[_Z14Serialize_implI13CSizeComputerNSt7__debug6vectorIhSaIhEEESaIS4_ES4_EvRT_RKNS2_IT0_T1_EERKT2_]+0x217): undefined reference to `__imp_pthread_mutex_unlock'
/usr/bin/x86_64-w64-mingw32-ld: consensus/.libs/libbitcoinconsensus_la-tx_check.o:tx_check.cpp:(.text$_Z14Serialize_implI13CSizeComputer5CTxInSaIS1_ES1_EvRT_RKNSt7__debug6vectorIT0_T1_EERKT2_[_Z14Serialize_implI13CSizeComputer5CTxInSaIS1_ES1_EvRT_RKNSt7__debug6vectorIT0_T1_EERKT2_]+0x1be): undefined reference to `__imp_pthread_mutex_lock'
/usr/bin/x86_64-w64-mingw32-ld: consensus/.libs/libbitcoinconsensus_la-tx_check.o:tx_check.cpp:(.text$_Z14Serialize_implI13CSizeComputer5CTxInSaIS1_ES1_EvRT_RKNSt7__debug6vectorIT0_T1_EERKT2_[_Z14Serialize_implI13CSizeComputer5CTxInSaIS1_ES1_EvRT_RKNSt7__debug6vectorIT0_T1_EERKT2_]+0x1d8): undefined reference to `__imp_pthread_mutex_unlock'
/usr/bin/x86_64-w64-mingw32-ld: consensus/.libs/libbitcoinconsensus_la-tx_check.o:tx_check.cpp:(.text$_Z14Serialize_implI13CSizeComputer6CTxOutSaIS1_ES1_EvRT_RKNSt7__debug6vectorIT0_T1_EERKT2_[_Z14Serialize_implI13CSizeComputer6CTxOutSaIS1_ES1_EvRT_RKNSt7__debug6vectorIT0_T1_EERKT2_]+0x1ba): undefined reference to `__imp_pthread_mutex_lock'
/usr/bin/x86_64-w64-mingw32-ld: consensus/.libs/libbitcoinconsensus_la-tx_check.o:tx_check.cpp:(.text$_Z14Serialize_implI13CSizeComputer6CTxOutSaIS1_ES1_EvRT_RKNSt7__debug6vectorIT0_T1_EERKT2_[_Z14Serialize_implI13CSizeComputer6CTxOutSaIS1_ES1_EvRT_RKNSt7__debug6vectorIT0_T1_EERKT2_]+0x1d1): undefined reference to `__imp_pthread_mutex_unlock'
/usr/bin/x86_64-w64-mingw32-ld: primitives/.libs/libbitcoinconsensus_la-block.o:block.cpp:(.text+0xd09): undefined reference to `__imp_pthread_mutex_lock'
/usr/bin/x86_64-w64-mingw32-ld: primitives/.libs/libbitcoinconsensus_la-block.o:block.cpp:(.text+0xd23): undefined reference to `__imp_pthread_mutex_unlock'
/usr/bin/x86_64-w64-mingw32-ld: primitives/.libs/libbitcoinconsensus_la-transaction.o:transaction.cpp:(.text+0x87b): undefined reference to `__imp_pthread_mutex_lock'
/usr/bin/x86_64-w64-mingw32-ld: primitives/.libs/libbitcoinconsensus_la-transaction.o:transaction.cpp:(.text+0x892): undefined reference to `__imp_pthread_mutex_unlock'
/usr/bin/x86_64-w64-mingw32-ld: primitives/.libs/libbitcoinconsensus_la-transaction.o:transaction.cpp:(.text+0x1df3): undefined reference to `__imp_pthread_mutex_lock'
/usr/bin/x86_64-w64-mingw32-ld: primitives/.libs/libbitcoinconsensus_la-transaction.o:transaction.cpp:(.text+0x1e0d): undefined reference to `__imp_pthread_mutex_unlock'
/usr/bin/x86_64-w64-mingw32-ld: primitives/.libs/libbitcoinconsensus_la-transaction.o:transaction.cpp:(.text+0x26f0): undefined reference to `__imp_pthread_mutex_lock'
/usr/bin/x86_64-w64-mingw32-ld: primitives/.libs/libbitcoinconsensus_la-transaction.o:transaction.cpp:(.text+0x270d): undefined reference to `__imp_pthread_mutex_unlock'
/usr/bin/x86_64-w64-mingw32-ld: primitives/.libs/libbitcoinconsensus_la-transaction.o:transaction.cpp:(.text+0x29d1): undefined reference to `__imp_pthread_mutex_unlock'
/usr/bin/x86_64-w64-mingw32-ld: primitives/.libs/libbitcoinconsensus_la-transaction.o:transaction.cpp:(.text+0x3009): undefined reference to `__imp_pthread_mutex_lock'
/usr/bin/x86_64-w64-mingw32-ld: primitives/.libs/libbitcoinconsensus_la-transaction.o:transaction.cpp:(.text$_Z14Serialize_implI11CHashWriterNSt7__debug6vectorIhSaIhEEESaIS4_ES4_EvRT_RKNS2_IT0_T1_EERKT2_[_Z14Serialize_implI11CHashWriterNSt7__debug6vectorIhSaIhEEESaIS4_ES4_EvRT_RKNS2_IT0_T1_EERKT2_]+0x669): undefined reference to `__imp_pthread_mutex_lock'
/usr/bin/x86_64-w64-mingw32-ld: primitives/.libs/libbitcoinconsensus_la-transaction.o:transaction.cpp:(.text$_Z14Serialize_implI11CHashWriterNSt7__debug6vectorIhSaIhEEESaIS4_ES4_EvRT_RKNS2_IT0_T1_EERKT2_[_Z14Serialize_implI11CHashWriterNSt7__debug6vectorIhSaIhEEESaIS4_ES4_EvRT_RKNS2_IT0_T1_EERKT2_]+0x680): undefined reference to `__imp_pthread_mutex_unlock'
/usr/bin/x86_64-w64-mingw32-ld: primitives/.libs/libbitcoinconsensus_la-transaction.o:transaction.cpp:(.text$_Z14Serialize_implI11CHashWriter5CTxInSaIS1_ES1_EvRT_RKNSt7__debug6vectorIT0_T1_EERKT2_[_Z14Serialize_implI11CHashWriter5CTxInSaIS1_ES1_EvRT_RKNSt7__debug6vectorIT0_T1_EERKT2_]+0x69b): undefined reference to `__imp_pthread_mutex_lock'
/usr/bin/x86_64-w64-mingw32-ld: primitives/.libs/libbitcoinconsensus_la-transaction.o:transaction.cpp:(.text$_Z14Serialize_implI11CHashWriter5CTxInSaIS1_ES1_EvRT_RKNSt7__debug6vectorIT0_T1_EERKT2_[_Z14Serialize_implI11CHashWriter5CTxInSaIS1_ES1_EvRT_RKNSt7__debug6vectorIT0_T1_EERKT2_]+0x6b5): undefined reference to `__imp_pthread_mutex_unlock'
/usr/bin/x86_64-w64-mingw32-ld: primitives/.libs/libbitcoinconsensus_la-transaction.o:transaction.cpp:(.text$_Z14Serialize_implI11CHashWriter6CTxOutSaIS1_ES1_EvRT_RKNSt7__debug6vectorIT0_T1_EERKT2_[_Z14Serialize_implI11CHashWriter6CTxOutSaIS1_ES1_EvRT_RKNSt7__debug6vectorIT0_T1_EERKT2_]+0x671): undefined reference to `__imp_pthread_mutex_lock'
/usr/bin/x86_64-w64-mingw32-ld: primitives/.libs/libbitcoinconsensus_la-transaction.o:transaction.cpp:(.text$_Z14Serialize_implI11CHashWriter6CTxOutSaIS1_ES1_EvRT_RKNSt7__debug6vectorIT0_T1_EERKT2_[_Z14Serialize_implI11CHashWriter6CTxOutSaIS1_ES1_EvRT_RKNSt7__debug6vectorIT0_T1_EERKT2_]+0x688): undefined reference to `__imp_pthread_mutex_unlock'
/usr/bin/x86_64-w64-mingw32-ld: script/.libs/libbitcoinconsensus_la-bitcoinconsensus.o:bitcoinconsensus.cpp:(.text$_ZN11__gnu_debug14_Safe_sequenceINSt7__debug6vectorIhSaIhEEEE16_M_invalidate_ifINS_15_After_nth_fromIN9__gnu_cxx17__normal_iteratorIPKhNSt9__cxx19986vectorIhS3_EEEEEEEEvT_[_ZN11__gnu_debug14_Safe_sequenceINSt7__debug6vectorIhSaIhEEEE16_M_invalidate_ifINS_15_After_nth_fromIN9__gnu_cxx17__normal_iteratorIPKhNSt9__cxx19986vectorIhS3_EEEEEEEEvT_]+0x34): undefined reference to `__imp_pthread_mutex_lock'
/usr/bin/x86_64-w64-mingw32-ld: script/.libs/libbitcoinconsensus_la-bitcoinconsensus.o:bitcoinconsensus.cpp:(.text$_ZN11__gnu_debug14_Safe_sequenceINSt7__debug6vectorIhSaIhEEEE16_M_invalidate_ifINS_15_After_nth_fromIN9__gnu_cxx17__normal_iteratorIPKhNSt9__cxx19986vectorIhS3_EEEEEEEEvT_[_ZN11__gnu_debug14_Safe_sequenceINSt7__debug6vectorIhSaIhEEEE16_M_invalidate_ifINS_15_After_nth_fromIN9__gnu_cxx17__normal_iteratorIPKhNSt9__cxx19986vectorIhS3_EEEEEEEEvT_]+0x53): undefined reference to `__imp_pthread_mutex_unlock'
/usr/bin/x86_64-w64-mingw32-ld: script/.libs/libbitcoinconsensus_la-interpreter.o:interpreter.cpp:(.text+0x5c60): undefined reference to `__imp_pthread_mutex_lock'
/usr/bin/x86_64-w64-mingw32-ld: script/.libs/libbitcoinconsensus_la-interpreter.o:interpreter.cpp:(.text+0x5c77): undefined reference to `__imp_pthread_mutex_unlock'
/usr/bin/x86_64-w64-mingw32-ld: script/.libs/libbitcoinconsensus_la-interpreter.o:interpreter.cpp:(.text+0x6560): undefined reference to `__imp_pthread_mutex_lock'
/usr/bin/x86_64-w64-mingw32-ld: script/.libs/libbitcoinconsensus_la-interpreter.o:interpreter.cpp:(.text+0x657a): undefined reference to `__imp_pthread_mutex_unlock'
/usr/bin/x86_64-w64-mingw32-ld: script/.libs/libbitcoinconsensus_la-interpreter.o:interpreter.cpp:(.text+0x6c3f): undefined reference to `__imp_pthread_mutex_lock'
/usr/bin/x86_64-w64-mingw32-ld: script/.libs/libbitcoinconsensus_la-interpreter.o:interpreter.cpp:(.text+0x6c59): undefined reference to `__imp_pthread_mutex_unlock'
/usr/bin/x86_64-w64-mingw32-ld: script/.libs/libbitcoinconsensus_la-interpreter.o:interpreter.cpp:(.text+0x7dbe): undefined reference to `__imp_pthread_mutex_lock'
/usr/bin/x86_64-w64-mingw32-ld: script/.libs/libbitcoinconsensus_la-interpreter.o:interpreter.cpp:(.text+0x7dd8): undefined reference to `__imp_pthread_mutex_unlock'
/usr/bin/x86_64-w64-mingw32-ld: script/.libs/libbitcoinconsensus_la-interpreter.o:interpreter.cpp:(.text+0x848f): undefined reference to `__imp_pthread_mutex_lock'
/usr/bin/x86_64-w64-mingw32-ld: script/.libs/libbitcoinconsensus_la-interpreter.o:interpreter.cpp:(.text+0x84a9): undefined reference to `__imp_pthread_mutex_unlock'
/usr/bin/x86_64-w64-mingw32-ld: script/.libs/libbitcoinconsensus_la-interpreter.o:interpreter.cpp:(.text+0x8b65): undefined reference to `__imp_pthread_mutex_lock'
/usr/bin/x86_64-w64-mingw32-ld: script/.libs/libbitcoinconsensus_la-interpreter.o:interpreter.cpp:(.text+0x8b7c): undefined reference to `__imp_pthread_mutex_unlock'
/usr/bin/x86_64-w64-mingw32-ld: script/.libs/libbitcoinconsensus_la-interpreter.o:interpreter.cpp:(.text+0x9239): undefined reference to `__imp_pthread_mutex_lock'
/usr/bin/x86_64-w64-mingw32-ld: script/.libs/libbitcoinconsensus_la-interpreter.o:interpreter.cpp:(.text+0x9250): undefined reference to `__imp_pthread_mutex_unlock'
/usr/bin/x86_64-w64-mingw32-ld: script/.libs/libbitcoinconsensus_la-interpreter.o:interpreter.cpp:(.text$_ZN11__gnu_debug14_Safe_sequenceINSt7__debug6vectorINS2_IhSaIhEEESaIS4_EEEE16_M_invalidate_ifINS_9_Equal_toIN9__gnu_cxx17__normal_iteratorIPKS4_NSt9__cxx19986vectorIS4_S5_EEEEEEEEvT_[_ZN11__gnu_debug14_Safe_sequenceINSt7__debug6vectorINS2_IhSaIhEEESaIS4_EEEE16_M_invalidate_ifINS_9_Equal_toIN9__gnu_cxx17__normal_iteratorIPKS4_NSt9__cxx19986vectorIS4_S5_EEEEEEEEvT_]+0x2e): undefined reference to `__imp_pthread_mutex_lock'
/usr/bin/x86_64-w64-mingw32-ld: script/.libs/libbitcoinconsensus_la-interpreter.o:interpreter.cpp:(.text$_ZN11__gnu_debug14_Safe_sequenceINSt7__debug6vectorINS2_IhSaIhEEESaIS4_EEEE16_M_invalidate_ifINS_9_Equal_toIN9__gnu_cxx17__normal_iteratorIPKS4_NSt9__cxx19986vectorIS4_S5_EEEEEEEEvT_[_ZN11__gnu_debug14_Safe_sequenceINSt7__debug6vectorINS2_IhSaIhEEESaIS4_EEEE16_M_invalidate_ifINS_9_Equal_toIN9__gnu_cxx17__normal_iteratorIPKS4_NSt9__cxx19986vectorIS4_S5_EEEEEEEEvT_]+0x4e): undefined reference to `__imp_pthread_mutex_unlock'
/usr/bin/x86_64-w64-mingw32-ld: script/.libs/libbitcoinconsensus_la-interpreter.o:interpreter.cpp:(.text$_ZN7CScriptC1EN11__gnu_debug14_Safe_iteratorIN9__gnu_cxx17__normal_iteratorIPKhNSt9__cxx19986vectorIhSaIhEEEEENSt7__debug6vectorIhS8_EESt26random_access_iterator_tagEESF_[_ZN7CScriptC1EN11__gnu_debug14_Safe_iteratorIN9__gnu_cxx17__normal_iteratorIPKhNSt9__cxx19986vectorIhSaIhEEEEENSt7__debug6vectorIhS8_EESt26random_access_iterator_tagEESF_]+0x328): undefined reference to `__imp_pthread_mutex_lock'
/usr/bin/x86_64-w64-mingw32-ld: script/.libs/libbitcoinconsensus_la-interpreter.o:interpreter.cpp:(.text$_ZN7CScriptC1EN11__gnu_debug14_Safe_iteratorIN9__gnu_cxx17__normal_iteratorIPKhNSt9__cxx19986vectorIhSaIhEEEEENSt7__debug6vectorIhS8_EESt26random_access_iterator_tagEESF_[_ZN7CScriptC1EN11__gnu_debug14_Safe_iteratorIN9__gnu_cxx17__normal_iteratorIPKhNSt9__cxx19986vectorIhSaIhEEEEENSt7__debug6vectorIhS8_EESt26random_access_iterator_tagEESF_]+0x342): undefined reference to `__imp_pthread_mutex_unlock'
/usr/bin/x86_64-w64-mingw32-ld: script/.libs/libbitcoinconsensus_la-interpreter.o:interpreter.cpp:(.text$_ZN11__gnu_debug14_Safe_sequenceINSt7__debug6vectorINS2_IhSaIhEEESaIS4_EEEE16_M_invalidate_ifINS_15_After_nth_fromIN9__gnu_cxx17__normal_iteratorIPKS4_NSt9__cxx19986vectorIS4_S5_EEEEEEEEvT_[_ZN11__gnu_debug14_Safe_sequenceINSt7__debug6vectorINS2_IhSaIhEEESaIS4_EEEE16_M_invalidate_ifINS_15_After_nth_fromIN9__gnu_cxx17__normal_iteratorIPKS4_NSt9__cxx19986vectorIS4_S5_EEEEEEEEvT_]+0x36): undefined reference to `__imp_pthread_mutex_lock'
/usr/bin/x86_64-w64-mingw32-ld: script/.libs/libbitcoinconsensus_la-interpreter.o:interpreter.cpp:(.text$_ZN11__gnu_debug14_Safe_sequenceINSt7__debug6vectorINS2_IhSaIhEEESaIS4_EEEE16_M_invalidate_ifINS_15_After_nth_fromIN9__gnu_cxx17__normal_iteratorIPKS4_NSt9__cxx19986vectorIS4_S5_EEEEEEEEvT_[_ZN11__gnu_debug14_Safe_sequenceINSt7__debug6vectorINS2_IhSaIhEEESaIS4_EEEE16_M_invalidate_ifINS_15_After_nth_fromIN9__gnu_cxx17__normal_iteratorIPKS4_NSt9__cxx19986vectorIS4_S5_EEEEEEEEvT_]+0x69): undefined reference to `__imp_pthread_mutex_unlock'
/usr/bin/x86_64-w64-mingw32-ld: script/.libs/libbitcoinconsensus_la-interpreter.o:interpreter.cpp:(.text$_ZN11__gnu_debug14_Safe_sequenceINSt7__debug6vectorIhSaIhEEEE16_M_invalidate_ifINS_9_Equal_toIN9__gnu_cxx17__normal_iteratorIPKhNSt9__cxx19986vectorIhS3_EEEEEEEEvT_[_ZN11__gnu_debug14_Safe_sequenceINSt7__debug6vectorIhSaIhEEEE16_M_invalidate_ifINS_9_Equal_toIN9__gnu_cxx17__normal_iteratorIPKhNSt9__cxx19986vectorIhS3_EEEEEEEEvT_]+0x2e): undefined reference to `__imp_pthread_mutex_lock'
/usr/bin/x86_64-w64-mingw32-ld: script/.libs/libbitcoinconsensus_la-interpreter.o:interpreter.cpp:(.text$_ZN11__gnu_debug14_Safe_sequenceINSt7__debug6vectorIhSaIhEEEE16_M_invalidate_ifINS_9_Equal_toIN9__gnu_cxx17__normal_iteratorIPKhNSt9__cxx19986vectorIhS3_EEEEEEEEvT_[_ZN11__gnu_debug14_Safe_sequenceINSt7__debug6vectorIhSaIhEEEE16_M_invalidate_ifINS_9_Equal_toIN9__gnu_cxx17__normal_iteratorIPKhNSt9__cxx19986vectorIhS3_EEEEEEEEvT_]+0x4e): undefined reference to `__imp_pthread_mutex_unlock'
/usr/bin/x86_64-w64-mingw32-ld: script/.libs/libbitcoinconsensus_la-interpreter.o:interpreter.cpp:(.text$_ZN7CScriptlsERKNSt7__debug6vectorIhSaIhEEE[_ZN7CScriptlsERKNSt7__debug6vectorIhSaIhEEE]+0x4ec): undefined reference to `__imp_pthread_mutex_lock'
/usr/bin/x86_64-w64-mingw32-ld: script/.libs/libbitcoinconsensus_la-interpreter.o:interpreter.cpp:(.text$_ZN7CScriptlsERKNSt7__debug6vectorIhSaIhEEE[_ZN7CScriptlsERKNSt7__debug6vectorIhSaIhEEE]+0x506): undefined reference to `__imp_pthread_mutex_unlock'
/usr/bin/x86_64-w64-mingw32-ld: script/.libs/libbitcoinconsensus_la-script.o:script.cpp:(.text+0x27f1): undefined reference to `__imp_pthread_mutex_lock'
/usr/bin/x86_64-w64-mingw32-ld: script/.libs/libbitcoinconsensus_la-script.o:script.cpp:(.text+0x280b): undefined reference to `__imp_pthread_mutex_unlock'
/usr/bin/x86_64-w64-mingw32-ld: script/.libs/libbitcoinconsensus_la-script.o:script.cpp:(.text$_Z6HexStrIN11__gnu_debug14_Safe_iteratorIN9__gnu_cxx17__normal_iteratorIPKhNSt9__cxx19986vectorIhSaIhEEEEENSt7__debug6vectorIhS8_EESt26random_access_iterator_tagEEENSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEET_SM_[_Z6HexStrIN11__gnu_debug14_Safe_iteratorIN9__gnu_cxx17__normal_iteratorIPKhNSt9__cxx19986vectorIhSaIhEEEEENSt7__debug6vectorIhS8_EESt26random_access_iterator_tagEEENSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEET_SM_]+0x6fa): undefined reference to `__imp_pthread_mutex_lock'
/usr/bin/x86_64-w64-mingw32-ld: script/.libs/libbitcoinconsensus_la-script.o:script.cpp:(.text$_Z6HexStrIN11__gnu_debug14_Safe_iteratorIN9__gnu_cxx17__normal_iteratorIPKhNSt9__cxx19986vectorIhSaIhEEEEENSt7__debug6vectorIhS8_EESt26random_access_iterator_tagEEENSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEET_SM_[_Z6HexStrIN11__gnu_debug14_Safe_iteratorIN9__gnu_cxx17__normal_iteratorIPKhNSt9__cxx19986vectorIhSaIhEEEEENSt7__debug6vectorIhS8_EESt26random_access_iterator_tagEEENSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEET_SM_]+0x714): undefined reference to `__imp_pthread_mutex_unlock'
/usr/bin/x86_64-w64-mingw32-ld: util/.libs/libbitcoinconsensus_la-strencodings.o:strencodings.cpp:(.text+0x3465): undefined reference to `__imp_pthread_mutex_lock'
/usr/bin/x86_64-w64-mingw32-ld: util/.libs/libbitcoinconsensus_la-strencodings.o:strencodings.cpp:(.text+0x347c): undefined reference to `__imp_pthread_mutex_unlock'
/usr/bin/x86_64-w64-mingw32-ld: util/.libs/libbitcoinconsensus_la-strencodings.o:strencodings.cpp:(.text+0x4263): undefined reference to `__imp_pthread_mutex_lock'
/usr/bin/x86_64-w64-mingw32-ld: util/.libs/libbitcoinconsensus_la-strencodings.o:strencodings.cpp:(.text+0x427a): undefined reference to `__imp_pthread_mutex_unlock'
collect2: error: ld returned 1 exit status
make[2]: *** [Makefile:7975: libbitcoinconsensus.la] Error 1
make[2]: Leaving directory '/home/hebasto/guix/GitHub/bitcoin/src'
make[1]: *** [Makefile:18819: all-recursive] Error 1
make[1]: Leaving directory '/home/hebasto/guix/GitHub/bitcoin/src'
make: *** [Makefile:794: all-recursive] Error 1
```


Discussion / hints:
The problem is that pthread gets dragged in as part of the machinery for `D_GLIBCXX_DEBUG`. This doesn't play nicely with the llibtool hacks we use to build fully static DLLs for Windows. I do have one idea about how we might fix this, but would probably like to get #19558 in first.

Also, this is a duplicate of the second issue in #19286. Maybe drop it from that issue so we can keep any discussion here.
> Also, this is a duplicate of the second issue in #19286. Maybe drop it from that issue so we can keep any discussion here.

#19266 updated.
@fanquake Do you mind looking into #21344 ?

Fix patch:
diff --git a/configure.ac b/configure.ac
index 72503f2b1cec5..5f09c8a5b6251 100644
--- a/configure.ac
+++ b/configure.ac
@@ -76,6 +76,12 @@ dnl we have those under control, re-enable that functionality.
 case $host in
   *mingw*)
      lt_cv_deplibs_check_method="pass_all"
+
+     dnl Remove unwanted -DDLL_EXPORT from these variables.
+     dnl We do not use this macro, but system headers may export unwanted symbols
+     dnl if it's set.
+     lt_cv_prog_compiler_pic="-DPIC"
+     lt_cv_prog_compiler_pic_CXX="-DPIC"
   ;;
 esac
 
diff --git a/src/Makefile.am b/src/Makefile.am
index 7b9ffe427dcd7..72e7db533488e 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -855,11 +855,12 @@ bitcoin_chainstate_SOURCES = bitcoin-chainstate.cpp
 bitcoin_chainstate_CPPFLAGS = $(AM_CPPFLAGS) $(BITCOIN_INCLUDES) $(BOOST_CPPFLAGS)
 bitcoin_chainstate_CXXFLAGS = $(AM_CXXFLAGS) $(PIE_FLAGS)
 
-# $(LIBTOOL_APP_LDFLAGS) deliberately omitted here so that we can test linking
-# bitcoin-chainstate against libbitcoinkernel as a shared or static library by
-# setting --{en,dis}able-shared.
-bitcoin_chainstate_LDFLAGS = $(RELDFLAGS) $(AM_LDFLAGS) $(PTHREAD_FLAGS)
+bitcoin_chainstate_LDFLAGS = $(RELDFLAGS) $(AM_LDFLAGS) $(PTHREAD_FLAGS) $(LIBTOOL_APP_LDFLAGS) -static
 bitcoin_chainstate_LDADD = $(LIBBITCOINKERNEL)
+
+# libtool is unable to calculate this indirect dependency, presumably because it's a subproject.
+# libsecp256k1 only needs to be linked in when libbitcoinkernel is static.
+bitcoin_chainstate_LDADD += $(LIBSECP256K1)
 #
 
 # bitcoinkernel library #
@@ -878,15 +879,6 @@ libbitcoinkernel_la_CPPFLAGS = $(AM_CPPFLAGS) -I$(builddir)/obj -I$(srcdir)/secp
 # to export from the library.
 libbitcoinkernel_la_CXXFLAGS = $(AM_CXXFLAGS) $(PIE_FLAGS) -fvisibility=default
 
-# TODO: For now, Specify -static in both CXXFLAGS and LDFLAGS when building for
-#       windows targets so libtool will only build a static version of this
-#       library. There are unresolved problems when building dll's for mingw-w64
-#       and attempting to statically embed libstdc++, libpthread, etc.
-if TARGET_WINDOWS
-libbitcoinkernel_la_LDFLAGS += -static
-libbitcoinkernel_la_CXXFLAGS += -static
-endif
-
 # TODO: libbitcoinkernel is a work in progress consensus engine library, as more
 #       and more modules are decoupled from the consensus engine, this list will
 #       shrink to only those which are absolutely necessary.


Test patch: