Ubuntu 下Bitcoin編譯,單步除錯環境搭建(step by step)
為了不被時代拋棄,連一聲再見都不說。最近開始研究bitcoin,主要是對C++比較熟。學習一項新技術,為達到效果,根據個人經驗從下面三個方面入手:
1. 買一本介紹原理的書,系統的瞭解,為什麼?因為書是別人智慧的總結,是一個完整的系統知識,站在前人肩膀遠勝過網路碎片化知識。
2. 實踐是最好的老師,唯有練才能領會其中的精髓。
3. 寫部落格,輸出倒逼輸入,強迫你學習之後自動理清思路總結,增加學習效果
----------------------------------------------------------------------------------------------------------
以下過程參考網上部分前人的總結實踐,首先向他們表示感謝。
比特幣 (貨幣符號: ฿;英文名:Bitcoin;英文縮寫: BTC),是一種用於開源的P2P軟體而產生的電子貨幣。比特幣全域性圖是這樣的:
下面開始Bitcoin的實踐之旅:
一. 預備知識
本人環境為ubutun14.04 ,。
二. 安裝知識
1. 更新系統的安裝庫,否則很多依賴庫無法從伺服器獲取。
apt-get update
2.先安裝一些必要的依賴庫
sudo apt-get install build-essential libtool autotools-dev autoconf pkg-config libssl-dev libevent-dev
sudo apt-get install libboost-all-dev
sudo apt-get install libdb-dev libdb++-dev
sudo apt-get install libminiupnpc-dev
sudo apt-get install libqt4-dev libprotobuf-dev protobuf-compiler
sudo apt-get install libqrencode-dev
sudo apt-get -y install libqt5gui5 libqt5core5a libqt5dbus5 qttools5-dev qttools5-dev-tools libprotobuf-dev protobuf-compiler libqrencode-dev
sudo apt-get install make gcc g++ git
3.下載原始碼
git clone https://github.com/bitcoin/bitcoin.git
4. 進入git clone的直接進入目錄
cd bitcoin
5.配置安裝資訊
./configure
如果你遇到這樣的提示:configure: error: Found Berkeley DB other than 4.8, required for portable wallets 那就可以這樣:
./configure --with-incompatible-bdb
配置完成後顯示配置選項
Options used to compile and link:
with wallet = yes
with gui / qt = yes
with qr = yes
with zmq = no
with test = yes
with bench = yes
with upnp = yes
use asm = yes
sanitizers =
debug enabled = no
gprof enabled = no
werror = no
target os = linux
build os =
CC = gcc
CFLAGS = -g -O2
CPPFLAGS = -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2 -DHAVE_BUILD_INFO -D__STDC_FORMAT_MACROS -D_FILE_OFFSET_BITS=64
CXX = g++ -std=c++11
CXXFLAGS = -Wstack-protector -fstack-protector-all -Wall -Wextra -Wformat -Wvla -Wformat-security -Wno-unused- parameter -g -O2
LDFLAGS = -pthread -Wl,-z,relro -Wl,-z,now -pie
ARFLAGS = cr
6.編譯,大約10分鐘
make
7.安裝
sudo make install
8. 執行
bitcoin-qt
執行GUI截圖:
9. DDD單步除錯
ddd bitcoin-qt&