首页 > 解决方案 > 比特币编译(.undefined 对 `BlockAssembler::BlockAssembler(CChainParams const&)' 的引用)

问题描述

make 命令后出现错误,例如,

未定义对“BlockAssembler::BlockAssembler(CChainParams const&)”的引用

最后

Makefile:774: 目标“全递归”的配方失败

make: **[all-recursive] 错误 1

我已按照此处给出的所有步骤进行操作:-

https://www.toshblocks.com/bitcoin/compile-bitcoin-source-code-ubuntu-16-04-lts/

输出 :-

 Making all in src
    make[1]: Entering directory '/home/khushbu/bitcoin/src'
    make[2]: Entering directory '/home/khushbu/bitcoin/src'
    make[3]: Entering directory '/home/khushbu/bitcoin'
    make[3]: Leaving directory '/home/khushbu/bitcoin'
      CXXLD    bitcoind
    libbitcoin_server.a(libbitcoin_server_a-mining.o): In function `generateBlocks(std::shared_ptr<CReserveScript>, int, unsigned long, bool)':
    /home/khushbu/bitcoin/src/rpc/mining.cpp:122: undefined reference to `BlockAssembler::BlockAssembler(CChainParams const&)'
    /home/khushbu/bitcoin/src/rpc/mining.cpp:122: undefined reference to `BlockAssembler::CreateNewBlock(CScript const&, bool)'
    /home/khushbu/bitcoin/src/rpc/mining.cpp:128: undefined reference to `IncrementExtraNonce(CBlock*, CBlockIndex const*, unsigned int&)'
    libbitcoin_server.a(libbitcoin_server_a-mining.o): In function `getmininginfo(JSONRPCRequest const&)':
    /home/khushbu/bitcoin/src/rpc/mining.cpp:216: undefined reference to `nLastBlockWeight'
    /home/khushbu/bitcoin/src/rpc/mining.cpp:217: undefined reference to `nLastBlockTx'
    libbitcoin_server.a(libbitcoin_server_a-mining.o): In function `getblocktemplate(JSONRPCRequest const&)':
    /home/khushbu/bitcoin/src/rpc/mining.cpp:521: undefined reference to `BlockAssembler::BlockAssembler(CChainParams const&)'
    /home/khushbu/bitcoin/src/rpc/mining.cpp:521: undefined reference to `BlockAssembler::CreateNewBlock(CScript const&, bool)'
    /home/khushbu/bitcoin/src/rpc/mining.cpp:533: undefined reference to `UpdateTime(CBlockHeader*, Consensus::Params const&, CBlockIndex const*)'
    collect2: error: ld returned 1 exit status
    Makefile:3888: recipe for target 'bitcoind' failed
    make[2]: *** [bitcoind] Error 1
    make[2]: Leaving directory '/home/khushbu/bitcoin/src'
    Makefile:10190: recipe for target 'all-recursive' failed
    make[1]: *** [all-recursive] Error 1
    make[1]: Leaving directory '/home/khushbu/bitcoin/src'
    Makefile:774: recipe for target 'all-recursive' failed
    make: *** [all-recursive] Error 1

如何解决这个错误并成功编译比特币源代码?

标签: c++makefileblockchainbitcoinbitcoind

解决方案


本教程帮助我解决了这个问题。

https://www.youtube.com/watch?v=l0A91Yx9juQ

通过,按照 Unix 构建说明,

https://github.com/bitcoin/bitcoin/blob/master/doc/build-UNIX.md

并下载所需的依赖项可以解决问题。我认为问题是由于 Berkeley DB 安装错误导致的,所以我删除了所有旧文件,然后再次按照 build-UNIX.md 中的步骤操作。

并下载依赖项,

sudo apt-get install build-essential libtool autotools-dev automake pkg-config bsdmainutils python3  

sudo apt-get install libssl-dev libevent-dev libboost-system-dev libboost-filesystem-dev libboost-chrono-dev libboost-test-dev libboost-thread-dev

sudo apt-get install software-properties-common
sudo add-apt-repository ppa:bitcoin/bitcoin
sudo apt-get update
sudo apt-get install libdb4.8-dev libdb4.8++-dev

这对我有用。谢谢!


推荐阅读