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項目比較大編譯的時間可能需要半小時,耐心等待吧

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM