bitshares研究系列【mac下安装bitshares】
安装
源代码
从github下载源代码,命令如下:
git clone https://github.com/bitshares/bitshares-core
git submodule update --init --recursive
环境
我机器上gcc版本还是4.0,先用brew安装最新版的各种工具再说
Chaim:bitshares-core Chaim$ brew install boost cmake git openssl autoconf automake
编译bitshares
Chaim:bitshares-core Chaim$ cmake .
此步报错,找不到boost库
CMake Error at libraries/fc/CMakeModules/FindBoost.cmake:1129 (message):
Unable to find the requested Boost libraries.
Boost version: 1.53.0
Boost include path: /usr/local/include
Detected version of Boost is too old. Requested version was 1.57 (or
newer).
下载Boost1.66版本,并编译安装,执行:
Chaim:bitshares-core Chaim$ cmake -DBOOST_ROOT=/usr/local/opt/boost -DOPENSSL_ROOT_DIR=/usr/local/opt/openssl .
-- Using custom FindBoost.cmake
-- Boost version: 1.66.0
-- Found the following Boost libraries:
-- thread
-- iostreams
-- date_time
-- system
-- filesystem
-- program_options
-- signals
-- serialization
-- chrono
-- unit_test_framework
-- context
-- locale
-- Using custom FindBoost.cmake
-- Boost version: 1.66.0
-- Found the following Boost libraries:
-- coroutine
-- Configuring BitShares on OS X
-- Configuring project fc located in: /Users/Chaim/Documents/workspace/bitshares-core/libraries/fc
-- Configuring fc to build on Unix/Apple
-- Using custom FindBoost.cmake
-- Boost version: 1.66.0
-- Found the following Boost libraries:
-- thread
-- date_time
-- system
-- filesystem
-- program_options
-- signals
-- serialization
-- chrono
-- unit_test_framework
-- context
-- locale
-- iostreams
-- coroutine
** websocketpp
=========== Used Build Configuration =============
-- ENABLE_CPP11 = ON
-- BUILD_EXAMPLES = OFF
-- BUILD_TESTS = OFF
-- WEBSOCKETPP_ROOT = /Users/Chaim/Documents/workspace/bitshares-core/libraries/fc/vendor/websocketpp
-- WEBSOCKETPP_BIN = /Users/Chaim/Documents/workspace/bitshares-core/libraries/fc/vendor/websocketpp/bin
-- WEBSOCKETPP_LIB = /Users/Chaim/Documents/workspace/bitshares-core/libraries/fc/vendor/websocketpp/lib
-- Install prefix = /usr/local
-- WEBSOCKETPP_BOOST_LIBS =
-- WEBSOCKETPP_PLATFORM_LIBS =
-- WEBSOCKETPP_PLATFORM_TLS_LIBS =
-- OPENSSL_FOUND = TRUE
-- OPENSSL_INCLUDE_DIR = /opt/local/include
-- OPENSSL_LIBRARIES = /opt/local/lib/libssl.a;/opt/local/lib/libcrypto.a
-- OPENSSL_VERSION = 1.0.2n
-- zlib found
-- bzip2 found
-- LOG_LONG_API: ON
--
-- LOGGING LONG API CALLS
-- MAX MS: 1000
-- WARN MS: 750
--
-- Finished fc module configuration...
-- Graphene database unity build enabled
-- egenesis: /Users/Chaim/Documents/workspace/bitshares-core/genesis.json
-- embed_genesis_args: -t/Users/Chaim/Documents/workspace/bitshares-core/libraries/egenesis/egenesis_brief.cpp.tmpl---/Users/Chaim/Documents/workspace/bitshares-core/libraries/egenesis/egenesis_brief.cpp-t/Users/Chaim/Documents/workspace/bitshares-core/libraries/egenesis/egenesis_full.cpp.tmpl---/Users/Chaim/Documents/workspace/bitshares-core/libraries/egenesis/egenesis_full.cpp--genesis-json/Users/Chaim/Documents/workspace/bitshares-core/genesis.json
-- Configuring done
-- Generating done
-- Build files have been written to: /Users/Chaim/Documents/workspace/bitshares-core
make
编译还是出错,赶紧仔细看README,里面说明需要Boost和OpenSSL的版本需求,按它的版本下载安装
**NOTE:** BitShares requires an [OpenSSL](https://www.openssl.org/) version in the 1.0.x series. OpenSSL 1.1.0 and newer are NOT supported. If your system OpenSSL version is newer, then you will need to manually provide an older version of OpenSSL and specify it to CMake using `-DOPENSSL_INCLUDE_DIR`, `-DOPENSSL_SSL_LIBRARY`, and `-DOPENSSL_CRYPTO_LIBRARY`.
**NOTE:** BitShares requires a [Boost](http://www.boost.org/) version in the range [1.57, 1.63]. Versions earlier than
1.57 or newer than 1.63 are NOT supported. If your system Boost version is newer, then you will need to manually build
an older version of Boost and specify it to CMake using `DBOOST_ROOT`.
看下现有安装版本:
Chaim:bitshares-core Chaim$ brew list openssl
/usr/local/Cellar/openssl/1.0.2o_1/.bottle/etc/ (8 files)
openssl是1.0.x
但刚安装的boost是1.66.0,这个版本太 高了,下个1.63试试,官网下载编译,运行cmake指定位置
Chaim:bitshares-core Chaim$ cmake -DBOOST_ROOT=/Users/Chaim/Documents/workspace/boost_1_63_0
再执行make
Chaim:bitshares-core Chaim$ make
[ 3%] Built target project_secp256k1
[ 6%] Built target project_editline
到70%居然还出错了...
[ 70%] Building CXX object libraries/net/CMakeFiles/graphene_net.dir/node.cpp.o
In file included from /Users/Chaim/Documents/workspace/bitshares-core/libraries/net/node.cpp:61:
In file included from /Users/Chaim/Documents/workspace/bitshares-core/libraries/fc/include/fc/thread/thread.hpp:5:
In file included from /Users/Chaim/Documents/workspace/bitshares-core/libraries/fc/include/fc/thread/task.hpp:2:
In file included from /Users/Chaim/Documents/workspace/bitshares-core/libraries/fc/include/fc/thread/future.hpp:5:
In file included from /Users/Chaim/Documents/workspace/bitshares-core/libraries/fc/include/fc/exception/exception.hpp:6:
In file included from /Users/Chaim/Documents/workspace/bitshares-core/libraries/fc/include/fc/log/logger.hpp:6:
In file included from /Users/Chaim/Documents/workspace/bitshares-core/libraries/fc/include/fc/log/log_message.hpp:8:
In file included from /Users/Chaim/Documents/workspace/bitshares-core/libraries/fc/include/fc/variant_object.hpp:2:
/Users/Chaim/Documents/workspace/bitshares-core/libraries/fc/include/fc/variant.hpp:334:27: error: ambiguous conversion for functional-style
cast from 'unsigned long' to 'fc::variant'
搜索到原因是mac的一些兼容问题,用develop版本已解决,试试:
Chaim:bitshares-core Chaim$ cd libraries/fc
Chaim:fc Chaim$ git checkout master
Chaim:fc Chaim$ git pull
Chaim:bitshares-core Chaim$ make clean
Chaim:bitshares-core Chaim$ make
执行,吃完中饭回来,结果如下:
[100%] Built target chain_test
Scanning dependencies of target generate_empty_blocks
[100%] Building CXX object tests/generate_empty_blocks/CMakeFiles/generate_empty_blocks.dir/main.cpp.o
[100%] Linking CXX executable generate_empty_blocks
[100%] Built target generate_empty_blocks
运行
Chaim:bitshares-core Chaim$ ./programs/witness_node/witness_node
1944344ms th_a main.cpp:134 create_new_config_fi ] Writing new config file at /Users/Chaim/Documents/workspace/bitshares-core/witness_node_data_dir/config.ini
1944348ms th_a witness.cpp:87 plugin_initialize ] witness plugin: plugin_initialize() begin
1944348ms th_a witness.cpp:97 plugin_initialize ] Public Key: BTS6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV
1944349ms th_a witness.cpp:115 plugin_initialize ] witness plugin: plugin_initialize() end
1944349ms th_a db_management.cpp:153 open ] Wiping object_database due to missing or wrong version
1944349ms th_a object_database.cpp:93 wipe ] Wiping object database...
1944349ms th_a object_database.cpp:95 wipe ] Done wiping object databse.
1944349ms th_a object_database.cpp:106 open ] Opening object database from /Users/Chaim/Documents/workspace/bitshares-core/witness_node_data_dir/blockchain ...
1944349ms th_a object_database.cpp:111 open ] Done opening object database.
1944350ms th_a application.cpp:330 operator() ] Initializing database...
OK!开始同步了!
附一 mac下安装boost
电脑上装的boost还是2013年创业做手游时1.53的版本,后来很少做这方面的开发,一直没有更新,最近有需要使用,连安装都忘了,这次把安装过程记录下来。
Chaim:boost_1_66_0 Chaim$ ./bootstrap.sh
Building Boost.Build engine with toolset darwin... tools/build/src/engine/bin.macosxx86_64/b2
Detecting Python version... 2.7
Detecting Python root... /opt/local/Library/Frameworks/Python.framework/Versions/2.7
Unicode/ICU support for Boost.Regex?... not found.
Generating Boost.Build configuration in project-config.jam...
Bootstrapping is done. To build, run:
./b2
To adjust configuration, edit 'project-config.jam'.
Further information:
- Command line help:
./b2 --help
- Getting started guide:
http://www.boost.org/more/getting_started/unix-variants.html
- Boost.Build documentation:
http://www.boost.org/build/doc/html/index.html
Chaim:boost_1_66_0 Chaim$ sudo ./b2 --buildtype=complete install
参考
https://github.com/bitshares/bitshares-core/issues/800?ref=tokendaily
https://github.com/bitshares/bitshares-core/wiki/Building-on-OS-X
感谢您阅读 @chaimyu 的帖子,期待您能留言交流!
你好cn区点赞机器人 @cnbuddy 谢谢你对cn区的贡献。假如我的留言打扰到你,请回复“取消”。