比特币源码编译配置

比特币源码编译配置,第1张

比特币源码环境配置编译

注:本文仅供自己参考
VMware® Workstation 16 Pro
ubuntu18.04
环境是重装的新环境,很多工具需要下载,下面如果有重复安装的请忽略

配置依赖包及基础工具 更新环境
#该命令需要在root下运行,没法root请用vi加在最后
echo 'deb-src http://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-backports main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-backports main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-proposed main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-proposed main restricted universe multiverse'>>/etc/apt/sources.list
#vi 方法
vi /etc/apt/sources.list
最后添加内容
deb-src http://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-backports main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-backports main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-proposed main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-proposed main restricted universe multiverse

更新全部资料库

apt-get update
下载依赖

本部分下载依赖包较多,单独下载太麻烦,所以制作一个shell脚本运行即可

使用vi/vim新建一个文件

vi update_setup.sh

将下面内容粘贴进update_setup.sh

sudo apt install -y git
sudo apt install -y vim
sudo apt-get install -y make
sudo apt-get install -y gcc
sudo apt-get install -y gcc-multilib
sudo apt-get install -y g++
sudo apt-get install -y libdb-dev
sudo apt-get install -y libdb++-dev
sudo apt-get install -y libboost-dev
sudo apt-get install -y libboost-all-dev
sudo apt-get install -y zlib1g-dev
sudo apt-get install -y libssl-dev
sudo apt-get install -y build-essential
sudo apt-get install -y libminiupnpc-dev
sudo apt-get install -y autoconf
sudo apt-get install -y libevent-dev
sudo apt-get install -y libzmq-dev
sudo apt-get install -y libzmq3-dev
sudo apt-get install -y libqt4-dev
sudo apt-get install -y libprotobuf-dev
sudo apt-get install -y protobuf-compiler
sudo apt-get install -y qt5-default qttools5-dev-tools

执行脚本

sh update_setup.sh

下载比特币源码/安装git
sudo apt-get install git-core
git clone https://github.com/bitcoin/bitcoin.git

如果git clone下载不了,443链接中断,可以直接上该网址将源码download下来,然后创建文件夹bitcoin,解压到其中

git直接下载zip压缩包

下载完成使用unzip解压

unzip bitcoin-master.zip

进入项目目录进行编译安装

cd bitcoin-master

编译安装

整个源码的有各种文件,其中有可执行文件autogen.sh和配置文件configure,用管理员身份赋予可执行权限

chmod u+x autogen.sh
#编译前准备
./autogen.sh
./configure –with-incompatible-bdb

执行./configure –with-incompatible-bdb 可能会出现这个错误

/bin/bash: ../share/genbuild.sh: Permission denied

要执行下面代码解决,之后再执行configure

chmod u+x share/genbuild.sh
#这里后面最好不要跟参数,如果要跟f请确认无误,否则会出错
./configure 

执行正确如下图:

编译代码并安装:

sudo make
sudo make install

编译过程及结果,如下图:

make

make install

打开程序
bitcoin-qt

最后看到是否同步数据的画面就说明安装成功,点击OK即可开始加载数据!

注:如果编译出现问题,参考下面解决问题方法即可

问题:

如果出现下面错误,说明GCC和G++版本不对,需要选在更新到7和8共存即可解决:

解决问题:

sudo apt install g++-8 gcc-8 
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-7 700 --slave /usr/bin/g++ g++ /usr/bin/g++-7
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-8 800 --slave /usr/bin/g++ g++ /usr/bin/g++-8

完成上面步骤之后,在进行make编译安装即可

sudo make
sudo make install

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/langs/759337.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-01
下一篇 2022-05-01

发表评论

登录后才能评论

评论列表(0条)

保存