ubuntu下编译bitcoin源代码

为了纪念比特币再创新高,今天我们编译一个bitcoin。
第一步:环境准备:
通过下面的的命令安装编译bitcoind所需要的依赖库:

sudo apt-get install build-essential libtool autotools-dev autoconf automake libssl-dev libboost-all-dev libdb-dev libdb++-dev pkg-config
sudo apt-get update

libevent安装过程:
1)进入官网 http://libevent.org/
2)下载libevent安装包:libevent-X.X.XX-stable.tar.gz,(最新版就行),然后解压。
3)切换到解压后的 libevent 主目录:cd libevent-X.X.XX-stable
4)执行如下:

sudo ./configure -prefix=/usr (或 sudo ./configure --program-prefix=/usr) 
sudo  make 
sudo  make install 

libevent会安装到 /usr/lib 或 /usr/local/lib 下
5)测试libevent是否安装成功:

ls -al /usr/lib | grep libevent(或 ls -al /usr/local/lib | grep libevent)

出现类似下图结果则表示安装成功:

cuijb@cuijb-VirtualBox:~$ ls -al /usr/lib | grep libevent
lrwxrwxrwx   1 root root      21 2月  29 13:33 libevent-2.1.so.7 -> libevent-2.1.so.7.0.0
-rwxr-xr-x   1 root root 1413112 2月  29 13:33 libevent-2.1.so.7.0.0
-rw-r--r--   1 root root 2341036 2月  29 13:33 libevent.a
lrwxrwxrwx   1 root root      26 2月  29 13:33 libevent_core-2.1.so.7 -> libevent_core-2.1.so.7.0.0
-rwxr-xr-x   1 root root  909944 2月  29 13:33 libevent_core-2.1.so.7.0.0
-rw-r--r--   1 root root 1536594 2月  29 13:33 libevent_core.a
-rwxr-xr-x   1 root root     982 2月  29 13:33 libevent_core.la
lrwxrwxrwx   1 root root      26 2月  29 13:33 libevent_core.so -> libevent_core-2.1.so.7.0.0
lrwxrwxrwx   1 root root      27 2月  29 13:33 libevent_extra-2.1.so.7 -> libevent_extra-2.1.so.7.0.0
-rwxr-xr-x   1 root root  530768 2月  29 13:33 libevent_extra-2.1.so.7.0.0
-rw-r--r--   1 root root  804514 2月  29 13:33 libevent_extra.a
-rwxr-xr-x   1 root root     989 2月  29 13:33 libevent_extra.la
lrwxrwxrwx   1 root root      27 2月  29 13:33 libevent_extra.so -> libevent_extra-2.1.so.7.0.0
-rwxr-xr-x   1 root root     947 2月  29 13:33 libevent.la
lrwxrwxrwx   1 root root      29 2月  29 13:33 libevent_openssl-2.1.so.7 -> libevent_openssl-2.1.so.7.0.0
-rwxr-xr-x   1 root root  119240 2月  29 13:33 libevent_openssl-2.1.so.7.0.0
-rw-r--r--   1 root root  166850 2月  29 13:33 libevent_openssl.a
-rwxr-xr-x   1 root root    1018 2月  29 13:33 libevent_openssl.la
lrwxrwxrwx   1 root root      29 2月  29 13:33 libevent_openssl.so -> libevent_openssl-2.1.so.7.0.0
lrwxrwxrwx   1 root root      30 2月  29 13:33 libevent_pthreads-2.1.so.7 -> libevent_pthreads-2.1.so.7.0.0
-rwxr-xr-x   1 root root   25800 2月  29 13:33 libevent_pthreads-2.1.so.7.0.0
-rw-r--r--   1 root root   25310 2月  29 13:33 libevent_pthreads.a
-rwxr-xr-x   1 root root    1010 2月  29 13:33 libevent_pthreads.la
lrwxrwxrwx   1 root root      30 2月  29 13:33 libevent_pthreads.so -> libevent_pthreads-2.1.so.7.0.0
lrwxrwxrwx   1 root root      21 2月  29 13:33 libevent.so -> libevent-2.1.so.7.0.0

第二部:编译bitcoin
1)去github上下载最新版本的bitcoin

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

2)编译源码所需要的库配置:

./autogen.sh

3)生成makefile文件:

./configure --without-gui --with-incompatible-bdb

若禁用钱包界面功能,仅提供比特币网络节点发现功能,可以使用以下命令:

./configure --without-gui  --disable-wallet

4)利用make进行编译:

make

5)(可选择不操作此步)安装编译好的二进制文件,命令如下:

sudo  make install

编译完成
6)检查bitcoin是否安装成功:

cuijb@cuijb-VirtualBox:~$ which bitcoind
/usr/local/bin/bitcoind

继续

cuijb@cuijb-VirtualBox:~$ which bitcoin-cli
/usr/local/bin/bitcoin-cli

恭喜你,bitcoin你已经编译成功了,下一步准备一展身手了。

你可能感兴趣的:(区块链开发,技术篇,区块链)