btcpool源码编译出错

下载了btcpool源码,想要在ubuntu16.04上面运行,可是编译不过~!

clipboard.png
难到源码真的有问题吗?有没有人碰到过此问题?
有谁有成功编译btcpool源码的经验?

+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

下面是我的详细编译过程:

在编译btcpool之前,一定要先下载安装bitcoin的源码
新建目录~/work/bitcoin 并进入,下载bitcoin的源码。

git clone https://github.com/bitcoin/bitcoin.git

安装此源码可能会报错,先做如下操作

sudo apt-get install libdb5.1++-dev
运行./autogen.sh
运行./configure --with-incompatible-bdb
然后再make , make install

新建目录~/work/code/并进入,下载btcpool源码

git clone https://github.com/btccom/btcpool.git

解压源码,进入根目录下面的install目录,运行install_btcpool.sh

sudo bash install_btcpool.sh

运行会报错,之后不要再次运行此脚本

进入btcpool-master的根目录,如果没有build目录则创建之,进入,运行cmake命令
注意:直接用cmake会出错,因为CMakeLists.txt里面有两个变量(CHAIN_TYPE, CHAIN_SRC_ROOT)需要定义,可以在CMakeLists.txt里面写死其定义

set(CHAIN_TYPE "BTC")
set(CHAIN_SRC_ROOT "/home/zc/work/bitcoin/bitcoin-master")

也可以在执行cmake时加入到参数里面(CHAIN_SRC_ROOT的地址是bitcoin源码的本地的地址)

cmake -DCHAIN_TYPE=BTC -DCHAIN_SRC_ROOT=/home/zc/work/bitcoin/bitcoin-master ..

然后make,可是出错了:

/home/zc/work/code/btcpool-master/src/Stratum.h:290:26: error: ‘CTxDestination’ does not name a type
                    const CTxDestination &poolPayoutAddr,
                          ^
In file included from /home/zc/work/code/btcpool-master/src/JobMaker.cc:24:0:
/home/zc/work/code/btcpool-master/src/JobMaker.h:65:3: error: ‘CTxDestination’ does not name a type
   CTxDestination poolPayoutAddr_;
   ^
/home/zc/work/code/btcpool-master/src/JobMaker.cc: In member function ‘bool JobMaker::init()’:
/home/zc/work/code/btcpool-master/src/JobMaker.cc:88:51: error: ‘IsValidDestinationString’ was not declared in this scope
   if (!IsValidDestinationString(poolPayoutAddrStr_)) {
                                                   ^
/home/zc/work/code/btcpool-master/src/JobMaker.cc:93:3: error: ‘poolPayoutAddr_’ was not declared in this scope
   poolPayoutAddr_ = DecodeDestination(poolPayoutAddrStr_);
   ^
/home/zc/work/code/btcpool-master/src/JobMaker.cc:93:57: error: ‘DecodeDestination’ was not declared in this scope
   poolPayoutAddr_ = DecodeDestination(poolPayoutAddrStr_);
                                                         ^
/home/zc/work/code/btcpool-master/src/JobMaker.cc: In member function ‘void JobMaker::sendStratumJob(const char*)’:
/home/zc/work/code/btcpool-master/src/JobMaker.cc:562:49: error: ‘poolPayoutAddr_’ was not declared in this scope
   if (!sjob.initFromGbt(gbt, poolCoinbaseInfo_, poolPayoutAddr_, blockVersion_,

难道源码有问题吗?此问题还待解决....

阅读 3.6k
1 个回答

源码没有问题,你只需要按照文档操作便可编译成功。

以 Ubuntu 16.04 LTS 为例,主要参考文档(均来自项目源码)如下

  1. bitcoin-0.16.0rc1/doc/build-unix.md
  2. btcpool/docs/INSTALL-BTCPool.md

下面是一键安装 btc-pool 脚本,主要参考上述文档,已测

#!/bin/bash
# 一键安装 btc-pool
#
# OS: Ubuntu 16.04 LTS
# @author 李毅
set -e

build_dir=/tmp

# 由 jarven 测试提供,https://segmentfault.com/q/1010000014060045?_ea=3538159
#   不需要兼容旧版 bitcoin,及不需要钱包功能的时候,可以使用系统默认的 libdb-dev
#   及 libdb++-dev 库,请把下一行的 false 改成 true。
use_latest_libdb=false

cpus=`grep -Ee 'processor\s:' /proc/cpuinfo | wc -l`


# 禁止 root 用户运行此脚本
#=========================
if [ "$UID" -eq 0 ] ; then
    echo "禁止 root 用户运行此脚本"
    exit 1
fi


# 创建临时目录
#=============
[ -d $build_dir ] || mkdir -p $build_dir


# 安装系统必要组件
#==================

# aptitude
if ! which aptitude >/dev/null 2>&1 ; then
    sudo apt-get update
    sudo apt-get install -y aptitude
fi

# 安装 libboost-all-dev 需要人工干预
if ! aptitude show libboost-all-dev > /dev/null 2>&1 ; then
    echo ""
    echo "!!! 安装 libboost-all-dev 需要人工干预,以降级某些依赖项的版本 !!!"
    echo "<1> 第一次询问时按下 'n' 键"
    echo "<2> 第二次询问时按下 'y' 键"
    aptitude install libboost-all-dev
fi

#
sudo aptitude install -y \
    build-essential autotools-dev libtool autoconf automake pkg-config cmake \
    openssl libssl-dev libcurl4-openssl-dev libconfig++-dev \
    libgmp-dev libmysqlclient-dev libzookeeper-mt-dev \
    libzmq3-dev libgoogle-glog-dev libevent-dev


# 编译安装 librdkafka-v0.9.1
#===========================
if ! pkg-config --libs rdkafka ; then
    sudo aptitude install -y zlib1g zlib1g-dev python
    cd $build_dir
    if [ ! -f librdkafka-0.9.1.tar.gz ]; then
        wget -O librdkafka-0.9.1.tar.gz https://github.com/edenhill/librdkafka/archive/0.9.1.tar.gz
        tar zxvf librdkafka-0.9.1.tar.gz
    fi
    cd librdkafka-0.9.1
    make clean
    ./configure
    make
    sudo make install
fi


# 编译 biticoin
#==============
sudo aptitude install -y \
    build-essential libtool autotools-dev automake pkg-config libssl-dev \
    libevent-dev bsdmainutils python3

if [ "$use_latest_libdb" = true ]; then
    sudo aptitude install -y libdb-dev libdb++-dev
else if ! aptitude show libdb4.8++-dev >/dev/null 2>&1 ; then
    # 安装低版 libdb4.8
    sudo apt-get install -y software-properties-common
    sudo add-apt-repository -y ppa:bitcoin/bitcoin
    sudo apt-get update
    sudo apt-get install -y libdb4.8-dev libdb4.8++-dev
fi

cd $build_dir
if [ ! -f bitcoin-0.16.0rc1.tar.gz ]; then
    wget -O bitcoin-0.16.0rc1.tar.gz https://github.com/bitcoin/bitcoin/archive/v0.16.0rc1.tar.gz
    tar zxf bitcoin-0.16.0rc1.tar.gz
fi
cd $build_dir/bitcoin-0.16.0rc1
./autogen.sh

if [ "$use_latest_libdb" = true ]; then
    ./configure --with-incompatible-bdb --disable-wallet
else
    ./configure
fi
make -j $cpus


# 编译 btcpool
#=============
cd $build_dir
if [ ! -d btcpool ]; then
    git clone https://github.com/btccom/btcpool.git
fi
cd $build_dir/btcpool
[ ! -d build ] && mkdir build
cd build

# Release build
cmake -DCHAIN_TYPE=BTC -DCHAIN_SRC_ROOT=$build_dir/bitcoin-0.16.0rc1 ..
make -j $cpus

若有问题,请随时留言。

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
1 篇内容引用
推荐问题