익명 00:29

Bitcoin fails to compile with Boost

Bitcoin fails to compile with Boost

After running 'autogen.sh', './configure' and then 'make', I keep getting the following error:

Undefined symbols for architecture x86_64: "__ZN5boost10filesystem4path5imbueERKSt6locale", referenced from: __Z16SetupEnvironmentv in libbitcoin_util.a(libbitcoin_util_a-system.o) ld: symbol(s) not found for architecture x86_64 collect2: error: ld returned 1 exit status make[2]: *** [bitcoind] Error 1 make[1]: *** [check-recursive] Error 1 make: *** [check-recursive] Error 1

I was told that boost is clang compiled and thus, GCC incompatible, so I've been trying to recompile boost with GCC via:

  1. HOMEBREW_CC=gcc-10 HOMEBREW_CXX=g++-10 brew install --build-from-source boost --HEAD
  2. `brew install boost --build-from-source --HEAD'

Both of these commands throw the following patching error though:

==> Patching ==> Applying 7b3fc734242eea9af734d6cd8ccb3d8f6b64c5b2.patch patching file boost-install.jam Hunk #1 FAILED at 483. 1 out of 1 hunk FAILED -- saving rejects to file boost-install.jam.rej

Any idea how to fix this problem and successfully recompile boost? Please let me know!

EDIT: For clarification, I'm trying to build Bitcoin Core v0.21.0 on macOS Catalina version 10.15.7

UPDATE: Finally got this working - turned out I had an outdated version of gcc installed via MacPorts, in addition to Apple's default compiler, which seemed to have been interfering with things. Once I uninstalled MacPorts, everything started working smoothly if I configured with --with-gui=no



Top Answer/Comment:

I just had this problem happen... On Mac OS 12.4, I installed boost with homebrew, and it was installed to /opt/homebrew/Cellar/boost/1.82.0_1

When I ran ./configure I got:

checking whether the Boost::System library is available... no
checking whether the Boost::Filesystem library is available... no
checking whether the Boost::Program_Options library is available... no
checking whether the Boost::Thread library is available... no
checking whether the Boost::Chrono library is available... no
checking whether the Boost::Unit_Test_Framework library is available... no
checking for dynamic linked boost test... no
checking for mismatched boost c++11 scoped enums... ok
configure: error: No working boost sleep implementation found.

So I added the with-boost flag with that path: ./configure --with-boost=/opt/homebrew/Cellar/boost/1.82.0_1

And then it worked. But running make failed for various reasons such as missing import statements, std::placeholder conflicting with boost::placeholder and other reasons... So I had to make the following changes:

diff --git a/src/httpserver.cpp b/src/httpserver.cpp
index e1763c6ad..66390c4e3 100644
--- a/src/httpserver.cpp
+++ b/src/httpserver.cpp
@@ -16,6 +16,7 @@
 #include <stdlib.h>
 #include <string.h>
 
+#include <deque>
 #include <sys/types.h>
 #include <sys/stat.h>
 #include <signal.h>
diff --git a/src/miner.h b/src/miner.h
index 3ba92b16b..993bde682 100644
--- a/src/miner.h
+++ b/src/miner.h
@@ -73,7 +73,7 @@ struct modifiedentry_iter {
 // except operating on CTxMemPoolModifiedEntry.
 // TODO: refactor to avoid duplication of this logic.
 struct CompareModifiedEntry {
-    bool operator()(const CTxMemPoolModifiedEntry &a, const CTxMemPoolModifiedEntry &b)
+    bool operator()(const CTxMemPoolModifiedEntry &a, const CTxMemPoolModifiedEntry &b) const
     {
         double f1 = (double)a.nModFeesWithAncestors * b.nSizeWithAncestors;
         double f2 = (double)b.nModFeesWithAncestors * a.nSizeWithAncestors;
@@ -88,7 +88,7 @@ struct CompareModifiedEntry {
 // This is sufficient to sort an ancestor package in an order that is valid
 // to appear in a block.
 struct CompareTxIterByAncestorCount {
-    bool operator()(const CTxMemPool::txiter &a, const CTxMemPool::txiter &b)
+    bool operator()(const CTxMemPool::txiter &a, const CTxMemPool::txiter &b) const
     {
         if (a->GetCountWithAncestors() != b->GetCountWithAncestors())
             return a->GetCountWithAncestors() < b->GetCountWithAncestors();
diff --git a/src/net_processing.cpp b/src/net_processing.cpp
index 3ec1a1c27..54a6c5f36 100644
--- a/src/net_processing.cpp
+++ b/src/net_processing.cpp
@@ -31,6 +31,7 @@
 #include "validationinterface.h"
 
 #include <boost/thread.hpp>
+#include <array>
 
 #if defined(NDEBUG)
 # error "Bitcoin cannot be compiled without assertions."
diff --git a/src/test/cuckoocache_tests.cpp b/src/test/cuckoocache_tests.cpp
index 00446aa11..29bc0acc7 100644
--- a/src/test/cuckoocache_tests.cpp
+++ b/src/test/cuckoocache_tests.cpp
@@ -7,6 +7,7 @@
 #include "random.h"
 #include <thread>
 #include <boost/thread.hpp>
+#include <deque>
 
 
 /** Test Suite for CuckooCache
diff --git a/src/txmempool.h b/src/txmempool.h
index db1a02455..05d68b645 100644
--- a/src/txmempool.h
+++ b/src/txmempool.h
@@ -229,7 +229,7 @@ struct mempoolentry_txid
 class CompareTxMemPoolEntryByDescendantScore
 {
 public:
-    bool operator()(const CTxMemPoolEntry& a, const CTxMemPoolEntry& b)
+    bool operator()(const CTxMemPoolEntry& a, const CTxMemPoolEntry& b) const
     {
         bool fUseADescendants = UseDescendantScore(a);
         bool fUseBDescendants = UseDescendantScore(b);
@@ -251,7 +251,7 @@ public:
     }
 
     // Calculate which score to use for an entry (avoiding division).
-    bool UseDescendantScore(const CTxMemPoolEntry &a)
+    bool UseDescendantScore(const CTxMemPoolEntry &a) const
     {
         double f1 = (double)a.GetModifiedFee() * a.GetSizeWithDescendants();
         double f2 = (double)a.GetModFeesWithDescendants() * a.GetTxSize();
@@ -266,7 +266,7 @@ public:
 class CompareTxMemPoolEntryByScore
 {
 public:
-    bool operator()(const CTxMemPoolEntry& a, const CTxMemPoolEntry& b)
+    bool operator()(const CTxMemPoolEntry& a, const CTxMemPoolEntry& b) const
     {
         double f1 = (double)a.GetModifiedFee() * b.GetTxSize();
         double f2 = (double)b.GetModifiedFee() * a.GetTxSize();
@@ -280,7 +280,7 @@ public:
 class CompareTxMemPoolEntryByEntryTime
 {
 public:
-    bool operator()(const CTxMemPoolEntry& a, const CTxMemPoolEntry& b)
+    bool operator()(const CTxMemPoolEntry& a, const CTxMemPoolEntry& b) const
     {
         return a.GetTime() < b.GetTime();
     }
@@ -289,7 +289,7 @@ public:
 class CompareTxMemPoolEntryByAncestorFee
 {
 public:
-    bool operator()(const CTxMemPoolEntry& a, const CTxMemPoolEntry& b)
+    bool operator()(const CTxMemPoolEntry& a, const CTxMemPoolEntry& b) const
     {
         double aFees = a.GetModFeesWithAncestors();
         double aSize = a.GetSizeWithAncestors();
@@ -656,7 +656,7 @@ public:
 
     /** Estimate priority needed to get into the next nBlocks */
     double estimatePriority(int nBlocks) const;
-    
+
     /** Write/Read estimates to disk */
     bool WriteFeeEstimates(CAutoFile& fileout) const;
     bool ReadFeeEstimates(CAutoFile& filein);
@@ -705,7 +705,7 @@ private:
     void removeUnchecked(txiter entry, MemPoolRemovalReason reason = MemPoolRemovalReason::UNKNOWN);
 };
 
-/** 
+/**
  * CCoinsView that brings transactions from a memorypool into view.
  * It does not check for spendings by memory pool transactions.
  */
diff --git a/src/validation.cpp b/src/validation.cpp
index fe8f8365b..6dcd1f0c4 100644
--- a/src/validation.cpp
+++ b/src/validation.cpp
@@ -170,6 +170,7 @@ private:
 
 public:
     MemPoolConflictRemovalTracker(CTxMemPool &_pool) : pool(_pool) {
+        using namespace boost::placeholders;
         pool.NotifyEntryRemoved.connect(boost::bind(&MemPoolConflictRemovalTracker::NotifyEntryRemoved, this, _1, _2));
     }
 
@@ -180,6 +181,7 @@ public:
     }
 
     ~MemPoolConflictRemovalTracker() {
+        using namespace boost::placeholders;
         pool.NotifyEntryRemoved.disconnect(boost::bind(&MemPoolConflictRemovalTracker::NotifyEntryRemoved, this, _1, _2));
         for (const auto& tx : conflictedTxs) {
             GetMainSignals().SyncTransaction(*tx, NULL, CMainSignals::SYNC_TRANSACTION_NOT_IN_BLOCK);
diff --git a/src/validationinterface.cpp b/src/validationinterface.cpp
index d4121a28b..3b89b1c2c 100644
--- a/src/validationinterface.cpp
+++ b/src/validationinterface.cpp
@@ -12,6 +12,8 @@ CMainSignals& GetMainSignals()
     return g_signals;
 }
 
+using namespace boost::placeholders;
+
 void RegisterValidationInterface(CValidationInterface* pwalletIn) {
     g_signals.UpdatedBlockTip.connect(boost::bind(&CValidationInterface::UpdatedBlockTip, pwalletIn, _1, _2, _3));
     g_signals.SyncTransaction.connect(boost::bind(&CValidationInterface::SyncTransaction, pwalletIn, _1, _2, _3));

and now I can run make and it works and built bitcoind and bitcoin-cli

상단 광고의 [X] 버튼을 누르면 내용이 보입니다