Compile Bitcoin Core from Source on Ubuntu
Ubuntu is often recommended as an operating system on which to run Bitcoin 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.
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 version installs 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.
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.
The Terminal application can alternatively be accessed through the keyboard shortcut Ctrl+Alt+T.
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
After a short time, all files should be ready. To confirm, use the
$ ls bitcoin
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
The last command should return a value of
Next, unpack the BerkeleyDB source and compile.
$ tar -xvf db-4.8.30.NC.tar.gz
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
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.
Running this command should bring up the Bitcoin Core welcome screen.