如何在没有网络的电脑上编译安装Bitcoin,以CentOS-6.10-x86_64系统为例。
先制作本地yum源并安装Bitcoin所需的依赖包,请参考:
Centos 制作本地源
上述依赖包安装完成后,接下去下载Bitcoin源码然后按照正常步骤编译安装比特币源码即可。
--------------------------------------------- 以下是解决编译安装Bitcoin源码过程中出现的问题---------------------------------------------
但是,要是这么简单制作一个本地yum源就轻松完成编译安装Bitcoin那也太轻松愉快了,实际编译安装过程中会遇到各种问题,请参考下面解决。
(1).若遇到autoconf版本太低的问题:
configure.ac:225: error: Autoconf version 2.64 or higher is required
build-aux/m4/ax_check_compile_flag.m4:60: AX_CHECK_COMPILE_FLAG is expanded from...
configure.ac:225: the top level
autom4te: /usr/bin/m4 failed with exit status: 63
aclocal: autom4te failed with exit status: 63
autoreconf: aclocal failed with exit status: 63
打开http://ftp.gnu.org/gnu/autoconf/autoconf-2.64.tar.gz下载/autoconf-2.64,解压后执行
./configure
make
make install
(2).若遇到configure.ac:1287: error: possibly undefined macro: PKG_CONFIG_LIBDIR问题:
configure.ac:1287: error: possibly undefined macro: PKG_CONFIG_LIBDIR
If this token and others are legitimate, please use m4_pattern_allow.
See the Autoconf documentation.
autoreconf: /usr/local/bin/autoconf failed with exit status: 1
打开bitcoin源码目录下的configure.ac文件,在m4_pattern_allow(DBOOST_AC_USE_STD_ATOMIC)下面新增一行:
m4_pattern_allow(PKG_CONFIG_LIBDIR)
这个问题是参考github上的 autogen.sh error: possibly undefined macro: PKG_CONFIG_LIBDIR #6432 这个问题进行解决的
(3).若遇到gcc需要升级的问题
configure: error: *** A compiler with support for C++11 language features is required.
查看当前gcc版本:
gcc version 4.4.7 20120313 (Red Hat 4.4.7-23) (GCC)
gcc版本是4.4.7,太低了,升级到6.4.0,可以参考 Centos升级gcc
(4) 若遇到Berkeley DB数据库报错::
checking for Berkeley DB C++ headers... no
configure: error: libdb_cxx headers missing, Bitcoin Core requires this library for wallet functionality (--disable-wallet to disable wallet functionality)
因为不用到钱包功能,所以加上–disable-wallet选项,即执行
./configure --disable-wallet
继续进行编译安装即可。
若希望使用钱包功能,则去http://www.oracle.com/technetwork/database/database-technologies/berkeleydb/downloads/index-082944.html下载Berkeley DB进行编译安装,可参考:https://github.com/bitcoin/bitcoin/issues/3686
(5)若遇到boost找不到的相关错误:
checking for boostlib >= 1.47.0... configure: We could not detect the boost libraries (version 1.47 or higher). If you have a staged boost library (still not installed) please specify $BOOST_ROOT in your environment and do not give a PATH to --with-boost option. If you are sure you have boost installed, then check your version number looking in . See http://randspringer.de/boost for more documentation.
checking whether the Boost::System library is available... yes
configure: error: Could not find a version of the boost_system library!
参照 https://blog.csdn.net/terminatorsong/article/details/74089911 这篇文章解决:
1)下载boost_1_64_0.tar.gz:
wget https://dl.bintray.com/boostorg/release/1.64.0/source/boost_1_64_0.tar.gz
tar zxvf boost_1_64_0.tar.gz
然后修改bootstrap.sh,将其中的 PREFIX=/usr/local 修改为 PREFIX=/usr,在下面找到 LIBDIR="EPREFIX/lib"修改为LIBDIR="EPREFIX/lib64”
注意:根据不同的系统可能会有不同,需要执行命令 whereis boost 进行检查,看头文件在哪里引用的,在最后install的时候会安装头文件到PREFIX/inlcude/boost里,所以要注意PREFIX的配置;而类库将会安装在LIBDIR里,有些系统会认/usr/lib,但有些只认/usr/lib64,需要根据情况修改。不然在bitcoin安装完成后会报找不到boost类库,无法运行的错误。
2)运行bootstrap.sh
bootstrap.sh是用来检查安装环境的,如果报错了,看一下是缺少了什么,安装一下即可。
cd boost_1_64_0
./bootstrap.sh
3)使用b2进行构建
sudo ./b2
(I)如果报错pyconfig.h找不到
先执行:
export CPLUS_INCLUDE_PATH=/usr/include/python2.6
然后查看,如果/usr/include/python2.6里的是pyconfig-64.h,则在/usr/include/python2.6路径下复制一份新的pyconfig-64.h,重命名成pyconfig.h
(II)如果报错patchlevel.h找不到
./boost/python/detail/wrap_python.hpp:75:24: fatal error: patchlevel.h: No such file or directory
则执行:
sudo yum install python-devel.x86_64
最后如果boost构建成功会看到:
The Boost C++ Libraries were successfully built!
The following directory should be added to compiler include paths:
/home/yzp/softwares/boost_1_64_0
The following directory should be added to linker library paths:
/home/yzp/softwares/boost_1_64_0/stage/lib
添加路径:
export CPLUS_INCLUDE_PATH="/home/yzp/softwares/boost_1_64_0"
export LIBRARY_PATH="/home/yzp/softwares/boost_1_64_0/stage/lib"
参考:
https://github.com/bitcoin/bitcoin/blob/master/doc/build-unix.md
CentOS6.7编译安装bitcoin钱包
CentOS下编译Bitcoin源码