Ubuntu compile bitcoin source code, solve dependencies

Source: Internet
Author: User
Tags create directory curl openssl git clone arch linux automake

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

UNIX Build NOTES

Some notes on the How to builds Bitcoin Core in Unix.

(for OpenBSD specific instructions, BUILD-OPENBSD.MD) Note

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

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

Here Bdb_prefix must was a absolute path-it is defined using $ (PWD) which ensuresthe usage of the absolute path. to build

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

This would build BITCOIN-QT as 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:

tr>
Library Purpose Description
miniupnpc UPnP Support firewall-jumping Support
li bdb4.8 Berkeley DB Wallet storage (only needed when Wallet enabled)
qt< /td> GUI GUI toolkit (only needed when GUI enabled)
protobuf Pay ments in GUI Data Interchange Format used to payment protocol (only needed when GUI enabled)
libqrencode qr codes in GUI Optional for generating QR codes (only needed when GUI Enab LEDs)
univalue Utility JSON Parsing and encoding (bundled version would b E used unless--with-system-univalue passed to configure)
libzmq3 zmq notification< /td> Optional, allows generating ZMQ notifications (requires ZMQ version >= 4.x)

For the versions used, dependencies.md Memory Requirements

C + + compilers are memory-hungry. It is recommended to have in 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 Pytho N3

Options when installing required Boost library files:

On in least Ubuntu 14.04+ and Debian 7+ there are generic for names boost theindividual development Wing 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

If that is 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. 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 would installberkeleydb 5.1 or later, which Break binary wallet compatibility with the distributed executables Whichare based on BerkeleyDB 4.8. If you don't care about wallet Compatibility,pass--with-incompatible-bdb to configure.

"Disable-wallet mode" to build Bitcoin Core without wallet.

Optional (--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 are want to build bitcoin-qt, make sure 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 would be used. Pass--WITH-GUI=QT4 to configure to choose Qt4.to builds without GUI pass--without-gui.

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

sudo apt-get install libqt5gui5 libqt5core5a libqt5dbus5 qttools5-dev qttools5-dev-tools Libprotobuf-dev Protobuf-compiler

Alternatively, to builds with Qt 4 and need the following:

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

Libqrencode (optional) can is installed with:

sudo apt-get install Libqrencode-dev

Once These are installed, they'll be found by configure and a BITCOIN-QT executable would 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-d Evel Python3

Optional:

sudo DNF install Miniupnpc-devel

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

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

Libqrencode (optional) can is installed with:

sudo DNF install Qrencode-devel
Notes

The release are built with GCC and then the strip Bitcoind to the Strip the DebugSymbols, which reduces the executable size by AB Out 90%. MINIUPNPC

MINIUPNPC May is used for UPnP port mapping. It can be downloaded from here. UPnP support is compiled in andturned out by default. The Configure options for UPnP behavior desired:

--WITHOUT-MINIUPNPC      No UPnP support MiniUPnP not required
--disable-upnp-default   (the default) UPnP Support turned from 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 are have to build it yourself:

 bitcoin_root=$ (PWD) # Pick Some path to install BDB to, here we create directory within the BITCOIN directory Bdb_ prefix= "${BITCOIN_ROOT}/DB4" Mkdir-p $BDB _prefix # Fetch The source and verify that it's 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 # builds the library and install to our prefix CD db-4.8.30.nc/build_unix/# Note:do A static build so this it can be embedded to the executable, instead of having t o Find A., at runtime. /dist/configure--enable-cxx--disable-shared--with-pic--prefix= $BDB _prefix make install # Configure-Core to us E our own-built instance of BDB CD $BITCOIN _root./autogen.sh./configure ldflags= "-l${bdb_prefix}/lib/" cppflags= "-I${BD" b_prefix}/include/"# (Other args ...) 

Note: Your only need Berkeley DB if the wallet are enabled (the section Disable-wallet mode below). Boost

If you are 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 is 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 spaces Layout Randomizationoffe Red by some kernels. Attackers who can cause execution's code at a arbitrary memorylocation are thwarted if they don ' t know where anything us Eful is located. The stack and heap are randomly located by default but this allows the code section to berandomly located as.

On a AMD64 processor where a library is not compiled with-fpic, this is cause an errorsuch as: "Relocation R_x86_64_3 2 against ' ... ' can not being used when making a shared object;

To test this 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 is built with a non-executable stackbut if one of the libraries it uses asks for a executable Stack or someone makes a mistakeand uses a compiler extension which requires an executable stack, it would silently build a Nexecutable without the non-executable stack protection.

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

The output should contain:stk/rel/ptlrw-r--rw-

The STK Rw-means that's readable and writeable but not executable. Disable-wallet Mode

When the intention are to run only a peer-to-peer node without a wallet, Bitcoin may being compiled Indisable-wallet mode with:

./configure--disable-wallet

In the case there be no dependency on Berkeley DB 4.8.

Mining is also possible in Disable-wallet mode, and 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 builds a command only, non-wallet distribution of the latest Chang Es 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-inco Mpatible-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 to the according. As mentioned above, when maintaining portability of the wallet between the standard Bitcoin Core distributions and Indepen dently Builtnode software is desired, Berkeley DB 4.8 must to be used. ARM cross-compilation

These steps can is performed on as example, an Ubuntu VM. The depends Systemwill also work on other Linux distributions, however the commands forinstalling the toolchain'll be di Fferent.

Make sure your 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, README.MD in the depends directory. Building on FreeBSD

(Updated as of FreeBSD 11.0)

Clang is installed by default as CC compiler, which makes it easier to getstarted in than on. Installing dependencies:

Pkg Install autoconf automake libtool pkgconf pkg install boost-libs OpenSSL libevent pkg install gmake

You are need to use GNU make (gmake) instead. (Libressl instead of OpenSSL to also work)

For the wallet (optional):

Pkg Install DB5

This is give a warning "configure:WARNING:Found Berkeley DB Otherthan 4.8; Wallets opened by this build is not to be portable!, but as FreeBSD Neverhad a binary. 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 to debugging:the version of GDB installed by the default is ancient and considered harmful. It isn't 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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.