您的位置:首页 > 其它

Compile Bitcoin Core from Source on Ubuntu

2015-11-07 00:11 465 查看


Ubuntu is often recommended as an operating system on which to runBitcoin Core. Although Bitcoin Core can be installed
as a precompiled binary, this method won't work in every case. This guide shows how to compile Bitcoin Core from scratch on a clean Ubuntu 14.04.2 system.


Why Compile?

The main reason to compile Bitcoin Core yourself is that it ensures you'll always have access to the latest release. For example, the binary Bitcoin Core package for Ubuntu 14.04 32-bit currently fails to install, giving the error message "E: Unable to locate
package bitcoin-qt" (the 64-bit versioninstalls without a problem). Compiling and installing from source eliminates the need to rely on precompiled
binaries when updating.

A secondary reason to compile from source is that it requires less trust. Although the maintainers of the Bitcoin Core binary package do a fine job, binaries are a few steps removed from raw source code. With each step comes to potential for unexpected issues
that can't be easily detected. Source code, in contrast, can be inspected before compilation and installation.

Yet another reason to compile from source is to enable custom behavior. For example, the Bitcoin Core GUI and wallet can be disabled if you plan to use the software without those features.


Prerequisites



Searching for the Terminal application.

The method for installing Bitcoin Core described here requires that you enter text-based commands. The preferred way to do this is through the Terminal application. To access it, click the swirl button in the upper left of the desktop and type "terminal". Click
the leftmost button labeled "Terminal" to launch the application.



Running the Terminal application. Commands are entered after the dollar sign.

The Terminal application can alternatively be accessed through the keyboard shortcut Ctrl+Alt+T.


Update

Ubuntu uses a package manager to simplify the downloading and installation of software components. Over time, the configuration of these packages becomes outdated. Ensure that your version of Ubuntu has the latest
package information with the following command. Enter your login password when prompted.
$ sudo apt-get update


Download the Source

We'll use Git to access the Bitcoin Core source code. In addition to providing the current version of Bitcoin Core, Git gives ready access to all past and future versions. Enter your
login password when prompted.
$ sudo apt-get install git

Next, create a source directory and clone the Bitcoin Core source repository.
$ mkdir -p src && cd src
$ git clone https://github.com/bitcoin/bitcoin.git

After a short time, all files should be ready. To confirm, use the
ls
command.
$ ls bitcoin


Install Dependencies

Bitcoin core requires many software libraries that don't come packaged by default with the Ubuntu distribution. The first one,
build-essential
,
enables software to be compiled from source.
$ sudo apt-get install build-essential

Bitcoin Core relies on an old version of the Berkeley Database that is not available as a standard Ubuntu 14.04 package. Although precompiled binaries can be downloaded, in this guide we'll compile from source.

Begin by downloading and verifying the BerkeleyDB source package.
$ 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

The last command should return a value of
db-4.8.30.NC.tar.gz: OK
.

Next, unpack the BerkeleyDB source and compile.
$ tar -xvf db-4.8.30.NC.tar.gz
$ cd db-4.8.30.NC/build_unix
$ mkdir -p build
$ BDB_PREFIX=$(pwd)/build
$ ../dist/configure --disable-shared --enable-cxx --with-pic --prefix=$BDB_PREFIX
$ make install
$ cd ../..

The remaining dependencies can be installed with a single command.
$ sudo apt-get install autoconf libboost-all-dev libssl-dev libprotobuf-dev protobuf-compiler libqt4-dev libqrencode-dev libtool


Compile Bitcoin Core

To compile Bitcoin Core, move back into the previously-cloned git repository and checkout the current release tag. At the time of the last update to this article, that version is 0.10.0. Tags can be listed with the command
git tag
.
For now, ignore the warning about "'detached HEAD' state". Next, configure build, and install the binaries.
$ cd bitcoin
$ git checkout v0.10.0
$ ./autogen.sh
$ ./configure CPPFLAGS="-I${BDB_PREFIX}/include/ -O2" LDFLAGS="-L${BDB_PREFIX}/lib/" --with-gui
$ make
$ sudo make install

Under the
bitcoin/doc
directory is a file called
build-unix.md
containing
more Linux build instructions and options.


Run Bitcoin Core

Bitcoin Core can now be run from the command line.
$ bitcoin-qt



The Bitcoin Core welcome screen.

Running this command should bring up the Bitcoin Core welcome screen.

from: http://bitzuma.com/posts/compile-bitcoin-core-from-source-on-ubuntu/
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: