導入
ブロックチェーンの勉強がてら、Bitcoin をインストールしたのでその記録を残しておきます。 MacBook Pro 2015, OS は High Sierra 10.13 で行いました。
公式のドキュメントはココにあります。
10/23 追記
brew install bitcoin
で一発ではいります
準備
OS X command line tools が必要なのでインストールしてない場合は以下を実行する。
$ xcode-select --install
依存ライブラリは以下で入る
$ brew install automake berkeley-db4 libtool boost --c++11 miniupnpc openssl pkg-config protobuf python3 qt libevent
リポジトリを以下から取得し移動
$ git clone https://github.com/bitcoin/bitcoin.git $ cd /path/to/bitcoin $ git checkout vv0.15.0rc3 (17/10/13 時点の最新版
ビルドする
以下の手順でコンパイルする。./configure --help
でオプションが表示できます。
ステップ3 はマシンスペックにもよりますが、30分くらいかかると思います。
autogen.sh
でOSや依存ライブラリのチェックを行っている./configure
でビルドスクリプトを生成する・make
でコンパイルを実行するsudo make install
でシステムのインストール先に配置
$ ./autogen.sh $ ./configure $ make $ sudo make install
確認
which コマンドでバイナリの配置を確認します。 これでインストールは終わりです。
$ which bitcoind /usr/local/bin/bitcoind $ which bitcoin-cli /usr/local/bin/bitcoin-cli
作業中の出来事
make 時に error: no matching function for call to 'upnpDiscover'
がでました。
原因は Bitcoin のバージョンが古かったためなので、最新版で実行することで解決できます。
~/w/g/b/bitcoin ❯❯❯ make tags/v0.9.5rc2^0 Making all in src /Applications/Xcode.app/Contents/Developer/usr/bin/make all-recursive Making all in . CXX addrman.o CXX alert.o CXX bloom.o CXX checkpoints.o CXX coins.o CXX init.o CXX keystore.o CXX leveldbwrapper.o CXX main.o CXX miner.o CXX net.o net.cpp:1066:15: error: no matching function for call to 'upnpDiscover' devlist = upnpDiscover(2000, multicastif, minissdpdpath, 0, 0, &error); ^~~~~~~~~~~~ /usr/local/include/miniupnpc/miniupnpc.h:62:1: note: candidate function not viable: requires 7 arguments, but 6 were provided upnpDiscover(int delay, const char * multicastif, ^ 1 error generated. make[3]: *** [net.o] Error 1 make[2]: *** [all-recursive] Error 1 make[1]: *** [all] Error 2 make: *** [all-recursive] Error 1
以下はコンパイル中の Warning集
特に調査してないです。
CXX libbitcoinconsensus_la-utilstrencodings.lo gcc -I. -g -O2 -Wall -Wextra -Wno-unused-function -c src/gen_context.c -o gen_context.o gcc gen_context.o -o gen_context ./gen_context CC src/libsecp256k1_la-secp256k1.lo CCLD libsecp256k1.la CXXLD libbitcoinconsensus.la clang: warning: argument unused during compilation: '-pthread' [-Wunused-command-line-argument] clang: warning: argument unused during compilation: '-pthread' [-Wunused-command-line-argument] CXX bitcoind-bitcoind.o bitcoind.cpp:153:17: warning: 'daemon' is deprecated: first deprecated in macOS 10.5 - Use posix_spawn APIs instead. [-Wdeprecated-declarations] if (daemon(1, 0)) { // don't chdir (1), do close FDs (0) ^ /usr/include/stdlib.h:293:6: note: 'daemon' has been explicitly marked deprecated here int daemon(int, int) __DARWIN_1050(daemon) __OSX_AVAILABLE_BUT_DEPRECATED_MSG(__MAC_10_0, __MAC_10_5, __IPHONE_2_0, __IPHONE_2_0, "Use posix_spawn APIs instead.") __WATCHOS_PROHIBITED __TVOS_PROHIBITED; ^ 1 warning generated.
CXX leveldb/util/leveldb_libleveldb_a-logging.o leveldb/util/logging.cc:58:40: warning: comparison of integers of different signs: 'const int' and 'unsigned long long' [-Wsign-compare] (v == kMaxUint64/10 && delta > kMaxUint64%10)) { ~~~~~ ^ ~~~~~~~~~~~~~ 1 warning generated.
CXX qt/qt_libbitcoinqt_a-notificator.o qt/notificator.cpp:66:27: warning: 'LSGetApplicationForInfo' is deprecated: first deprecated in macOS 10.10 - Use LSCopyDefaultApplicationURLForContentType instead. [-Wdeprecated-declarations] OSStatus status = LSGetApplicationForInfo(kLSUnknownType, kLSUnknownCreator, CFSTR("growlTicket"), kLSRolesAll, 0, &cfurl); ^ /System/Library/Frameworks/CoreServices.framework/Frameworks/LaunchServices.framework/Headers/LSInfoDeprecated.h:633:1: note: 'LSGetApplicationForInfo' has been explicitly marked deprecated here LSGetApplicationForInfo( ^ 1 warning generated.
まとめ
ドキュメントの通りにやれば40分くらいで Bitcoin がインストールできます。 実際に実行するのも書けたら書きます😇