笔记:Centos7 编译Bitshares Core(full node)

in bitshares •  6 years ago 

前言

bitshares官方是在ubuntu环境下编译,Centos7编译过程大致相同,也遇到一些坑,本文以供参考。


编译

1、安装Boost_1_57_0版本
bitshares支持的Boost版本范围是:1.57- 1.65,太高或太低都不行。

wget https://nchc.dl.sourceforge.net/project/boost/boost/1.57.0/boost_1_57_0.tar.gz
tar -xf boost_1_57_0.tar.gz
cd boost_1_57_0
./bootstrap.sh
./b2
sudo cp -rf boost /usr/include
sudo cp -rf stage/lib/* /usr/lib64

2、安装依赖

yum install libzip-devel
yum install bzip2-devel
yum install libdbi-devel
yum install readline-devel
yum install autoconf
yum install libtool
yum install ntp

3、编译bitshares

git clone https://github.com/bitshares/bitshares-core.git

cd bitshares-core

git checkout <LATEST_RELEASE_TAG>
#查看最新版本https://github.com/bitshares/bitshares-core/releases, 如:git checkout 2.0.180202

git submodule update --init --recursive

cmake -DCMAKE_BUILD_TYPE=RelWithDebInfo .

make

4、运行节点

 cd /root/bitshares/bitshares-core/programs/witness_node

./witness_node -d ./node_data  --partial-operations true --track-account '"1.2.786642"' --track-account '"1.2.514416"' --track-account '"1.2.749822"' --track-account '"1.2.749799"' --track-account '"1.2.691115"' --track-account '"1.2.664208"' --rpc-endpoint
# 注:--track-account '"1.2.786642”'只跟踪我们关心的账号,较少内存消耗

测试:

curl http://localhost:8090 -d '{"jsonrpc": "2.0", "method": "get_block", "params": [1], "id": 1}’

本地ws为:

ws://localhost:8090

##问题与解决

问题1:

致命错误:curl/curl.h:没有那个文件或目录

解决:

yum install libcurl-devel

问题2:

没有规则可以创建“libraries/fc/tests/all_tests”需要的目标“/usr/lib64/openssl/libcrypto.so”。 停止。

解决:
cmake指定openssl库路径,只支持openssl 1.0.x,不支持更新的1.1.x

cmake -DOPENSSL_INCLUDE_DIR=/usr/lib64/ -DOPENSSL_SSL_LIBRARY=/usr/lib64/libssl.so -DOPENSSL_CRYPTO_LIBRARY=/usr/lib64/libcrypto.so .

其中libcrypto.so和libssl.so位置可通过find命令查找出来。

问题3:

CMake Error at CMakeLists.txt:15 (message):
GCC version must be at least 4.8!

解决:
升级GCC

yum install centos-release-scl
yum install devtoolset-3-toolchain
scl enable devtoolset-3 bash

查看版本:
gcc —version

把 /usr/bin/c++, /usr/bin/cc替换为最新版本:

 cp /opt/rh/devtoolset-2/root/usr/bin/cc /usr/bin/cc
cp /usr/local/bin/c++ /usr/bin/c++

修改cmake编译器版本及默认路径:
打开文件bitshares/bitshares-core/CMakeFiles/2.8.12.2/CMakeCXXCompiler.cmake
将以下内容

set(CMAKE_CXX_IMPLICIT_LINK_DIRECTORIES "/usr/lib/gcc/x86_64-redhat-linux/4.4.7;/usr/lib64;/lib64;/usr/lib”)

改为

set(CMAKE_CXX_IMPLICIT_LINK_DIRECTORIES " /usr/local/bin/;/usr/lib64;/lib64;/usr/lib”)
set(CMAKE_CXX_COMPILER_VERSION "4.8.5”)
Authors get paid when people like you upvote their post.
If you enjoyed what you read here, create your account today and start earning FREE STEEM!