https://github.com/bitcoin/bitcoin/blob/master/doc/build-unix.md

UNIX BUILD NOTES

Some notes on how to build Bitcoin Core in Unix.

(for OpenBSD specific instructions,see build-openbsd.md)

Note

Always use absolute paths to configure and compile bitcoin and the dependencies,for example,when specifying the path of the dependency:

../dist/configure --enable-cxx --disable-shared --with-pic --prefix=$BDB_PREFIX

Here BDB_PREFIX must be an absolute path - it is defined using $(pwd) which ensuresthe usage of the absolute path.

To Build

./autogen.sh
./configure
make
make install # optional

This will build bitcoin-qt as well if the dependencies are met.

Dependencies

These dependencies are required:

Library Purpose Description
libssl Crypto Random Number Generation,Elliptic Curve Cryptography
libboost Utility Library for threading,data structures,etc
libevent Networking OS independent asynchronous networking

Optional dependencies:

Library Purpose Description
miniupnpc UPnP Support Firewall-jumping support
libdb4.8 Berkeley DB Wallet storage (only needed when wallet enabled)
qt GUI GUI toolkit (only needed when GUI enabled)
protobuf Payments in GUI Data interchange format used for payment protocol (only needed when GUI enabled)
libqrencode QR codes in GUI Optional for generating QR codes (only needed when GUI enabled)
univalue Utility JSON parsing and encoding (bundled version will be used unless --with-system-univalue passed to configure)
libzmq3 ZMQ notification Optional,allows generating ZMQ notifications (requires ZMQ version >= 4.x)

For the versions used,see dependencies.md

Memory Requirements

C++ compilers are memory-hungry. It is recommended to have at least 1.5 GB ofmemory available when compiling Bitcoin Core. On systems with less,gcc can betuned to conserve memory with additional CXXFLAGS:

./configure CXXFLAGS="--param ggc-min-expand=1 --param ggc-min-heapsize=32768"

Dependency Build Instructions: Ubuntu & Debian

Build requirements:

sudo apt-get install build-essential libtool autotools-dev automake pkg-config libssl-dev libevent-dev bsdmainutils python3

Options when installing required Boost library files:

  1. On at least Ubuntu 14.04+ and Debian 7+ there are generic names for theindividual boost development packages,so the following can be used to onlyinstall necessary parts of boost:

    sudo apt-get install libboost-system-dev libboost-filesystem-dev libboost-chrono-dev libboost-program-options-dev libboost-test-dev libboost-thread-dev
  2. If that doesn't work,you can install all boost development packages with:

    sudo apt-get install libboost-all-dev

BerkeleyDB is required for the wallet.

For Ubuntu only: db4.8 packages are available here.You can add the repository and install using the following commands:

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

Ubuntu and Debian have their own libdb-dev and libdb++-dev packages,but these will installBerkeleyDB 5.1 or later,which break binary wallet compatibility with the distributed executables whichare based on BerkeleyDB 4.8. If you do not care about wallet compatibility,pass --with-incompatible-bdb to configure.

See the section "disable-wallet mode" to build Bitcoin Core without wallet.

Optional (see --with-miniupnpc and --enable-upnp-default):

sudo apt-get install libminiupnpc-dev

ZMQ dependencies (provides ZMQ API 4.x):

sudo apt-get install libzmq3-dev

Dependencies for the GUI: Ubuntu & Debian

If you want to build Bitcoin-Qt,make sure that the required packages for Qt developmentare installed. Either Qt 5 or Qt 4 are necessary to build the GUI.If both Qt 4 and Qt 5 are installed,Qt 5 will be used. Pass --with-gui=qt4 to configure to choose Qt4.To build without GUI pass --without-gui.

To build with Qt 5 (recommended) you need the following:

sudo apt-get install libqt5gui5 libqt5core5a libqt5dbus5 qttools5-dev qttools5-dev-tools libprotobuf-dev protobuf-compiler

Alternatively,to build with Qt 4 you need the following:

sudo apt-get install libqt4-dev libprotobuf-dev protobuf-compiler

libqrencode (optional) can be installed with:

sudo apt-get install libqrencode-dev

Once these are installed,they will be found by configure and a bitcoin-qt executable will bebuilt by default.

Dependency Build Instructions: Fedora

Build requirements:

sudo dnf install gcc-c++ libtool make autoconf automake openssl-devel libevent-devel boost-devel libdb4-devel libdb4-cxx-devel python3

Optional:

sudo dnf install miniupnpc-devel

To build with Qt 5 (recommended) you need the following:

sudo dnf install qt5-qttools-devel qt5-qtbase-devel protobuf-devel

libqrencode (optional) can be installed with:

sudo dnf install qrencode-devel

Notes

The release is built with GCC and then "strip bitcoind" to strip the debugsymbols,which reduces the executable size by about 90%.

miniupnpc

miniupnpc may be used for UPnP port mapping. It can be downloaded from here. UPnP support is compiled in andturned off by default. See the configure options for upnp behavior desired:

--without-miniupnpc      No UPnP support miniupnp not required
--disable-upnp-default   (the default) UPnP support turned off by default at runtime
--enable-upnp-default    UPnP support turned on by default at runtime

Berkeley DB

It is recommended to use Berkeley DB 4.8. If you have to build it yourself:

BITCOIN_ROOT=$(pwd)

# Pick some path to install BDB to,here we create a directory within the bitcoin directory
BDB_PREFIX="${BITCOIN_ROOT}/db4"
mkdir -p $BDB_PREFIX

# Fetch the source and verify that it is not tampered with
wget 'http://download.oracle.com/berkeley-db/db-4.8.30.NC.tar.gz'
echo '12edc0df75bf9abd7f82f821795bcee50f42cb2e5f76a6a281b85732798364ef  db-4.8.30.NC.tar.gz' | sha256sum -c
# -> db-4.8.30.NC.tar.gz: OK
tar -xzvf db-4.8.30.NC.tar.gz

# Build the library and install to our prefix
cd db-4.8.30.NC/build_unix/
#  Note: Do a static build so that it can be embedded into the executable,instead of having to find a .so at runtime
../dist/configure --enable-cxx --disable-shared --with-pic --prefix=$BDB_PREFIX
make install

# Configure Bitcoin Core to use our own-built instance of BDB
cd $BITCOIN_ROOT
./autogen.sh
./configure LDFLAGS="-L${BDB_PREFIX}/lib/" CPPFLAGS="-I${BDB_PREFIX}/include/" # (other args...)

Note: You only need Berkeley DB if the wallet is enabled (see the section disable-Wallet mode below).

Boost

If you need to build Boost yourself:

sudo su
./bootstrap.sh
./bjam install

Security

To help make your bitcoin installation more secure by making certain attacks impossible toexploit even if a vulnerability is found,binaries are hardened by default.This can be disabled with:

Hardening Flags:

./configure --enable-hardening
./configure --disable-hardening

Hardening enables the following features:

  • Position Independent ExecutableBuild position independent code to take advantage of Address Space Layout Randomizationoffered by some kernels. Attackers who can cause execution of code at an arbitrary memorylocation are thwarted if they don't kNow where anything useful is located.The stack and heap are randomly located by default but this allows the code section to berandomly located as well.

    On an AMD64 processor where a library was not compiled with -fPIC,this will cause an errorsuch as: "relocation R_X86_64_32 against `......' can not be used when making a shared object;"

    To test that you have built PIE executable,install scanelf,part of paxutils,and use:

    scanelf -e ./bitcoin

    The output should contain:

    TYPEET_DYN

  • Non-executable StackIf the stack is executable then trivial stack based buffer overflow exploits are possible ifvulnerable buffers are found. By default,bitcoin should be built with a non-executable stackbut if one of the libraries it uses asks for an executable stack or someone makes a mistakeand uses a compiler extension which requires an executable stack,it will silently build anexecutable without the non-executable stack protection.

    To verify that the stack is non-executable after compiling use:scanelf -e ./bitcoin

    the output should contain:STK/REL/PTLRW- R-- RW-

    The STK RW- means that the stack is readable and writeable but not executable.

disable-wallet mode

When the intention is to run only a P2P node without a wallet,bitcoin may be compiled indisable-wallet mode with:

./configure --disable-wallet

In this case there is no dependency on Berkeley DB 4.8.

Mining is also possible in disable-wallet mode,but only using the getblocktemplate RPCcall not getwork.

Additional Configure Flags

A list of additional configure flags can be displayed with:

./configure --help

Setup and Build Example: Arch Linux

This example lists the steps necessary to setup and build a command line only,non-wallet distribution of the latest changes on Arch Linux:

pacman -S git base-devel boost libevent python
git clone https://github.com/bitcoin/bitcoin.git
cd bitcoin/
./autogen.sh
./configure --disable-wallet --without-gui --without-miniupnpc
make check

Note:Enabling wallet support requires either compiling against a Berkeley DB newer than 4.8 (package db) using --with-incompatible-bdb,or building and depending on a local version of Berkeley DB 4.8. The readily available Arch Linux packages are currently built using--with-incompatible-bdb according to the PKGBUILD.As mentioned above,when maintaining portability of the wallet between the standard Bitcoin Core distributions and independently builtnode software is desired,Berkeley DB 4.8 must be used.

ARM Cross-compilation

These steps can be performed on,an Ubuntu VM. The depends systemwill also work on other Linux distributions,however the commands forinstalling the toolchain will be different.

Make sure you install the build requirements mentioned above.Then,install the toolchain and curl:

sudo apt-get install g++-arm-linux-gnueabihf curl

To build executables for ARM:

cd depends
make HOST=arm-linux-gnueabihf NO_QT=1
cd ..
./configure --prefix=$PWD/depends/arm-linux-gnueabihf --enable-glibc-back-compat --enable-reduce-exports LDFLAGS=-static-libstdc++
make

For further documentation on the depends system see README.md in the depends directory.

Building on FreeBSD

(Updated as of FreeBSD 11.0)

Clang is installed by default as cc compiler,this makes it easier to getstarted than on OpenBSD. Installing dependencies:

pkg install autoconf automake libtool pkgconf
pkg install boost-libs openssl libevent
pkg install gmake

You need to use GNU make (gmake) instead of make.(libressl instead of openssl will also work)

For the wallet (optional):

pkg install db5

This will give a warning "configure: WARNING: Found Berkeley DB otherthan 4.8; wallets opened by this build will not be portable!",but as FreeBSD neverhad a binary release,this may not matter. If backwards compatibilitywith 4.8-built Bitcoin Core is needed follow the steps under "Berkeley DB" above.

Then build using:

./autogen.sh
./configure --with-incompatible-bdb BDB_CFLAGS="-I/usr/local/include/db5" BDB_LIBS="-L/usr/local/lib -ldb_cxx-5"
gmake

Note on debugging: The version of gdb installed by default is ancient and considered harmful.It is not suitable for debugging a multi-threaded C++ program,not even for getting backtraces. Please install the package gdb anduse the versioned gdb command e.g. gdb7111.

ubuntu 中编译bitcoin源码,解决依赖项的更多相关文章

  1. Ubuntu下编译安装Bitcoin

    参考:Ubuntu上编译安装BitcoinCore比特币源码的编译及环境搭建一、安装第三方库:1.安装libssl,libevent,libboost库等:sudoapt-getinstallbuild-essentiallibtoolautotools-devautomakepkg-configlibssl-devlibevent-devbsdmainutilssudoapt-getinstal

  2. Ubuntu下编译windows版本bitcoin

    要编译windows版的比特币程序,基本上有两种方法,一种是在linux平台通过交叉编译的方法来编译,另外一种就是直接在windows平台编译。下面就详细介绍一下如何在Ubuntu平台编译比特币程序。

  3. Ubuntu编译运行bitcoin运行全节点之Error处理

    错误内容解决办法增加虚拟机内存空间到1.5G顺利进行~

  4. Ubuntu编译运行bitcoin运行全节点

    比特币源码linux下环境配置编译运行bitcoin时间:2017-03-04来源:linux网站作者:Mosen_Huang由于近期学习区块链,需要学习下比特币源码,所以尝试着在windows和Linux环境下编译运行,但是windows下的环境配置很繁琐总是在装qt的时候报错,下面贴一下在linux环境下的配置和运行步骤(ubuntu)github源码链接(https://github.com

  5. CentOS6.7编译安装bitcoin钱包

    不然在bitcoin安装完成后会报找不到boost类库,无法运行的错误。查查问题的时候都是关于bitcoin的,提到的都是要使用BerkeleyDb4.8NC。CentOS没有libdb,只能手动安装BerkeleyDb5.1。六、执行bitcoin/bin下的命令这个时候可能会有找不到类库的错误,这时参才在安装boost的时候配置的boost安装路径,如果没配可以直接复制类库过去。然后bitcoin安装就完成了。

  6. ubuntu 中编译bitcoin源码,解决依赖项

    https://github.com/bitcoin/bitcoin/blob/master/doc/build-unix.mdUNIXBUILDNOTESSomenotesonhowtobuildBitcoinCoreinUnix.(forOpenBSDspecificinstructions,seebuild-openbsd.md)NoteAlwaysuseabsolutepathstocon

  7. 2、如何在Ubuntu16.04下编译生成Bitcoin

    硬盘20G操作系统:Ubuntu16.04Desktop我用的是VM虚拟机安装的Ubuntu16.04安装所依赖的库:02下载源代码bitcore的源码目前在github上.bitcore的核心是BitcoinCore,基于这个Core,Bitcoin有两个实现,一个是Bitcoin-qt,一个是bitcoind,其中bitcoind是没有界面GUI,而Bitcoin-qt是有界面的实现。下面我来看如何生成有界面的Gui,即Bitcoin-qt.首先要安装依赖库:编译:编译成功后会有src/qt目录下面生

  8. Ubuntu上安装Bitcoin Unlimited

    以前写过一篇Ubuntu上安装BitcoinCore的文章,当前比特币扩容之争还在继续,今天决定把Ubuntu上面的BitcoinCore换成BitcoinUnlimited。下面对安装BitcoinUnlimited的过程做个总结。备份好你们的钱包,备份好你的私钥备份好~/.bitcon目录的数据,这里存放的是全部的区块数据,如果区块数据丢失或者损坏,需要重建索引,或者需要重新下载。停止运行bitcoind:bitcoin-clistop备份好数据以及停止了bitcoind,下一步需要移除Bitcoin

随机推荐

  1. crontab发送一个月份的电子邮件

    ubuntu14.04邮件服务器:Postfixroot收到来自crontab的十几封电子邮件.这些邮件包含PHP警告.>我已经解决了这些警告的原因.>我已修复每个cronjobs不发送电子邮件(输出发送到>/dev/null2>&1)>我删除了之前的所有电子邮件/var/mail/root/var/spool/mail/root但我仍然每小时收到十几封电子邮件.这些电子邮件来自cronjobs,

  2. 模拟两个ubuntu服务器计算机之间的慢速连接

    我想模拟以下场景:假设我有4台ubuntu服务器机器A,B,C和D.我想在机器A和机器C之间减少20%的网络带宽,在A和B之间减少10%.使用网络模拟/限制工具来做到这一点?

  3. ubuntu-12.04 – 如何在ubuntu 12.04中卸载从源安装的redis?

    我从源代码在Ubuntu12.04上安装了redis-server.但在某些时候它无法完全安装,最后一次makeinstallcmd失败.然后我刚刚通过apt包安装.现在我很困惑哪个安装正在运行哪个conf文件?实际上我想卸载/删除通过源安装的所有内容,只是想安装一个包.转到源代码树并尝试以下命令:如果这不起作用,您可以列出软件自行安装所需的步骤:

  4. ubuntu – “apt-get source”无法找到包但“apt-get install”和“apt-get cache”可以找到它

    我正在尝试下载软件包的源代码,但是当我运行时它无法找到.但是当我运行apt-cache搜索squid3时,它会找到它.它也适用于apt-getinstallsquid3.我使用的是Ubuntu11.04服务器,这是我的/etc/apt/sources.list我已经多次更新了.我尝试了很多不同的debs,并没有发现任何其他地方的错误.这里的问题是你的二进制包(deb)与你的源包(deb-src)不

  5. ubuntu – 有没有办法检测nginx何时完成正常关闭?

    &&touchrestarted),因为即使Nginx没有完成其关闭,touch命令也会立即执行.有没有好办法呢?这样的事情怎么样?因此,pgrep将查找任何Nginx进程,而while循环将让它坐在那里直到它们全部消失.你可以改变一些有用的东西,比如睡1;/etc/init.d/Nginx停止,以便它会休眠一秒钟,然后尝试使用init.d脚本停止Nginx.你也可以在某处放置一个计数器,这样你就可以在需要太长时间时发出轰击信号.

  6. ubuntu – 如何将所有外发电子邮件从postfix重定向到单个地址进行测试

    我正在为基于Web的应用程序设置测试服务器,该应用程序发送一些电子邮件通知.有时候测试是使用真实的客户数据进行的,因此我需要保证服务器在我们测试时无法向真实客户发送电子邮件.我想要的是配置postfix,以便它接收任何外发电子邮件并将其重定向到一个电子邮件地址,而不是传递到真正的目的地.我正在运行ubuntu服务器9.10.先感谢您设置本地用户以接收所有被困邮件:你需要在main.cf中添加:然后

  7. ubuntu – vagrant无法连接到虚拟框

    当我使用基本的Vagrantfile,只配置了两条线:我看到我的虚拟框打开,但是我的流氓日志多次显示此行直到超时:然后,超时后的一段时间,虚拟框框终于要求我登录,但是太久了!所以我用流氓/流氓记录.然后在我的物理机器上,如果我“流氓ssh”.没有事情发生,直到:怎么了?

  8. ubuntu – Nginx – 转发HTTP AUTH – 用户?

    我和Nginx和Jenkins有些麻烦.我尝试使用Nginx作为Jenkins实例的反向代理,使用HTTP基本身份验证.它到目前为止工作,但我不知道如何传递带有AUTH用户名的标头?}尝试将此指令添加到您的位置块

  9. Debian / Ubuntu – 删除后如何恢复/ var / cache / apt结构?

    我在ubuntu服务器上的空间不足,所以我做了这个命令以节省空间但是现在在尝试使用apt时,我会收到以下错误:等等显然我删除了一些目录结构.有没有办法做apt-getrebuild-var-tree或类似的?

  10. 检查ubuntu上安装的rubygems版本?

    如何查看我的ubuntu盒子上安装的rubygems版本?只是一个想法,列出已安装的软件包和grep为ruby或宝石或其他:)dpkg–get-selections

返回
顶部