2015年3月27日金曜日

bitcoin 本家のソースをコンパイルした

こちらに分かりやすい手順があるのでそれに従う。

まずは、依存関係のインストール。


sudo apt-get update
sudo apt-get upgrade
sudo apt-get -f install
sudo apt-get install build-essential libtool autotools-dev autoconf pkg-config libssl-dev
sudo apt-get install libboost-all-dev
sudo apt-get install libqt4-dev libprotobuf-dev protobuf-compiler
sudo apt-get install libqt5gui5 libqt5core5a libqt5dbus5 qttools5-dev qttools5-dev-tools libprotobuf-dev protobuf-compiler
sudo apt-get install libqrencode-dev


ソースを適当な場所へgithub からコピー(クローン)


cd ~
git clone git://github.com/bitcoin/bitcoin.git




このままmake すると、wallet に必要なBerkleyDB が無いので怒られる。BerkleyDB は Oracle社の AGPLv3 ライセンスなので、apt-get でインストールできない。さらに、最新版v5.1 はサポートされていないので、v4.8 を使用しなければならない。それらが考慮された本家の手順書ページに書いてあるスクリプトを使用してBerkleyDB ダウンロードする。




cd ~/bitcoin
vi myinstall.sh

以下のコードを張り付け
------------------ ここから ------------------
BITCOIN_ROOT=$(pwd)

# Pick some path to install BDB to, here we create a directory within the bitcoin directory
BDB_PREFIX="${BITCOIN_ROOT}/db4"
mkdir -p $BDB_PREFIX

# Fetch the source and verify that it is not tampered with
wget 'http://download.oracle.com/berkeley-db/db-4.8.30.NC.tar.gz'
echo '12edc0df75bf9abd7f82f821795bcee50f42cb2e5f76a6a281b85732798364ef  db-4.8.30.NC.tar.gz' | sha256sum -c
# -> db-4.8.30.NC.tar.gz: OK
tar -xzvf db-4.8.30.NC.tar.gz

# Build the library and install to our prefix
cd db-4.8.30.NC/build_unix/
#  Note: Do a static build so that it can be embedded into the executable, instead of having to find a .so at runtime
../dist/configure --enable-cxx --disable-shared --with-pic --prefix=$BDB_PREFIX
make install

# Configure Bitcoin Core to use our own-built instance of BDB
cd $BITCOIN_ROOT
./configure LDFLAGS="-L${BDB_PREFIX}/lib/" CPPFLAGS="-I${BDB_PREFIX}/include/"
------------------ ここまで ------------------

chmod 744 myinstall.sh


※補足 最終行から (other args...) を削除してある

いよいよコンパイル。




./autogen.sh
./myinstall.sh
make
make install



make は130分かかった。(on raspberry pi 2)


そして実行!




cd /usr/local/bin
./bitcoin-qt



こんな画面が出てくる。






自分はなぜか、起動時に qt や x11 関連のエラーが出てしまった。
x11-apps を入れて、xclock が表示されることを確認したり、再起動をしているうちにいつの間にか直った。


sudo apt-get install x11-apps



コンパイルすると勉強になるなぁ。

0 件のコメント:

コメントを投稿