ubuntu环境下编译bitcoin(比特币)全过程

1.首先从github上clone最新的bitcoin源代码

git clone https://github.com/bitcoin/bitcoin.git

2.进入clone下来的代码目录,查看当前版本(这里我切换到了v0.20.0版本)

cd ./bitcoin
git tag -l
git checkout v0.20.0

3.安装autoconf,安装成功之后运行代码目录下的./autogen.sh

sudo apt install autoconf
./autogen.sh

4.出现了错误信息,configure: error: PKG_PROG_PKG_CONFIG macro not found. Please install pkg-config and re-run autogen.sh,提示安装libtool,如果没有安装gcc,g++还需要安装这两项,安装完成之后再一次运行./autogen.sh应该就可以成功了,运行成功之后会在代码目录下生成./configure

sudo apt install libtool gcc g++
./autogen.sh

5.运行./configure,出现错误,需要安装pkg-config之后重新./autogen.sh(倒退回上面步骤了) 

sudo apt install pkg-config
./autogen.sh

6.再次报错,configure: error: libdb_cxx headers missing, Bitcoin Core requires this library for wallet functionality (--disable-wallet to disable wallet functionality),安装libdb++-dev可解决问题,安装之后重新./configure

sudo apt install libdb++-dev

7.出现了一个警告和一个错误,

checking for QT5... no
configure: WARNING: Qt dependencies not found; bitcoin-qt frontend will not be built
checking whether to build Bitcoin Core GUI... no
checking for Berkeley DB C++ headers... default
configure: error: Found Berkeley DB other than 4.8, required for portable wallets (--with-incompatible-bdb to ignore or --disable-wallet to disable wallet functionality)

或者qt5安装之后有警告

configure: WARNING: LRELEASE not found; bitcoin-qt frontend will not be built

需要安装qt5-default和qttools5-dev-tools,以及从源代码编译Berkeley DB

sudo apt install qt5-default qttools5-dev-tools

编译Berkeley DB

wget http://download.oracle.com/berkeley-db/db-4.8.30.NC.tar.gz
tar -xzvf db-4.8.30.NC.tar.gz
cd db-4.8.30.NC/build_unix
../dist/configure --enable-cxx
make
sudo make install

8.加入参数重新运行./configure

./configure CPPFLAGS="-I/usr/local/BerkeleyDB.4.8/include -O2" LDFLAGS="-L/usr/local/BerkeleyDB.4.8/lib"

报错

checking for boostlib >= 1.47.0 (104700)... configure: We could not detect the boost libraries (version MINIMUM_REQUIRED_BOOST or higher). If you have a staged boost library (still not installed) please specify $BOOST_ROOT in your environment and do not give a PATH to --with-boost option. If you are sure you have boost installed, then check your version number looking in <boost/version.hpp>. See http://randspringer.de/boost for more documentation.
checking whether the Boost::System library is available... no
checking whether the Boost::Filesystem library is available... no
checking whether the Boost::Thread 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
checking for QR... no
checking for EVENT... no
configure: error: libevent version 2.0.21 or greater not found.

把这些依赖一下装齐了吧

sudo apt install libevent-dev libzmq5-dev doxygen libboost1.58-all-dev

然后重新

./configure CPPFLAGS="-I/usr/local/BerkeleyDB.4.8/include -O2" LDFLAGS="-L/usr/local/BerkeleyDB.4.8/lib"

这个时候依然还是有一个警告,目前暂未找到解决的方法,但是不影响编译的功能

configure: WARNING: "xgettext is required to update qt translations"

9../configure没有问题,之后就可以make了,bitcoin项目比较大编译的时间可能需要半小时,耐心等待吧

 

posted @ 2020-06-30 12:15  鸡毛巾  阅读(2331)  评论(0编辑  收藏  举报