比特币源码编译

in bitcoin •  7 years ago 

环境

我用的是linux ubuntu 16.04镜像,请确保运行内存大于2G。要不然编译不成功。

源码地址

https://github.com/bitcoin/bitcoin

doc文档的位置

1、linux系统构建文档
https://github.com/bitcoin/bitcoin/blob/master/doc/build-unix.md
2、windows系统构建文档
https://github.com/bitcoin/bitcoin/blob/master/doc/build-windows.md
3、Mac系统构建文档
https://github.com/bitcoin/bitcoin/blob/master/doc/build-osx.md

操作步骤

  1. 更新ubuntu源列表(源列表:下载软件时会去源列表的地址中查找)
    sudo apt-get apdate
    源列表的位置: /etc/apt/sources.list

  2. 下载依赖
    sudo apt-get install build-essential libtool autotools-dev automake pkg-config libssl-dev libevent-dev bsdmainutils python3
    sudo apt-get install libqt5gui5 libqt5core5a libqt5dbus5 qttools5-dev qttools5-dev-tools libprotobuf-dev protobuf-compiler
    sudo apt-get install libboost-system-dev libboost-filesystem-dev libboost-chrono-dev libboost-program-options-dev libboost-test-dev libboost-thread-dev
    sudo apt-get install libboost-all-dev
    sudo apt-get install libqrencode-dev
    sudo apt-get install libminiupnpc-dev
    sudo apt-get install software-properties-common
    sudo add-apt-repository ppa:bitcoin/bitcoin
    sudo apt-get update
    sudo apt-get install libdb4.8-dev libdb4.8++-dev

  3. 安装git
    sudo apt-get install git

  4. 下载源代码
    mkdir ~/blockchain新建一个目录存放bitcoin源代码
    cd ~/blockchain进入文件夹
    git clone https://github.com/bitcoin/bitcoin.git 下载源代码

  5. 安装berkeley-db
    (1)、在比特币源码文件夹内创建db4文件夹
    mkdir -p ~/blockchain/bitcoin/db4
    (2)、下载berkeley-db安装包
    cd ~/blockchain/bitcoin/db4 进入db4文件夹
    wget 'http://download.oracle.com/berkeley-db/db-4.8.30.NC.tar.gz' 下载安装包
    (3)、解压缩安装包
    tar -zxvf db-4.8.30.NC.tar.gz
    (4)、进入build_unix文件夹
    cd ~/blockchain/bitcoin/db4/db-4.8.30.NC/build_unix/
    (5)、执行命令
    ../dist/configure --enable-cxx --disable-shared --with-pic --prefix=/root/blockchain/bitcoin/db4/
    --prifix=后面的是db4的绝对路径。也就是进入/db4文件夹输入pwd获取到的绝对路径
    输入ls命令查看文件列表
    输入make install
    打印信息最后一行会出现

  6. 安装bitcoin客户端
    (1)、进入bitcoin文件夹
    cd ~/blockchain/bitcoin/
    (2)、执行命令
    ./autogen.sh
    ./configure LDFLAGS="-L/root/blockchain/bitcoin/db4/lib/" CPPFLAGS="-I/root/blockchain/bitcoin/db4/include/"
    注意:将LDFLAGS="-L/root/blockchain/bitcoin/db4/lib/" 和CPPFLAGS="-I/root/blockchain/bitcoin/db4/include/" 换成你自己的绝对路径
    make
    make install
    (3)、检查是否安装成功
    which bitcoind
    which bitcoin-cli
    输出结果
    (4)、遇到的问题
    a 、在执行./configure命令时报错:
    configure: error: hexdump is required for tests
    解决方法:sudo apt-get install bsdmainutils
    b、重新执行之后报错:libevent not found
    libevent not found
    解决方法:sudo apt-get install libevent-dev
    c、执行成功后出现:
    成功后出现

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!
Sort Order:  

Congratulations @markcoder! You have received a personal award!

1 Year on Steemit
Click on the badge to view your Board of Honor.

Do you like SteemitBoard's project? Then Vote for its witness and get one more award!

Congratulations @markcoder! You received a personal award!

Happy Birthday! - You are on the Steem blockchain for 2 years!

You can view your badges on your Steem Board and compare to others on the Steem Ranking

Vote for @Steemitboard as a witness to get one more award and increased upvotes!