Libbitcoin offers several options for installation.
Firstly, If you would like to simply use libbitcoin’s bitcoin functionality without having to write any code you can download the signed executable binaries for some of the libbitcoin applications. These binaries require no installation and are programs simply meant to be run on your machine. Binaries exist for the libbitcoin-node, libbitcoin-server, and libbitcoin-explorer applications. The most useful, for beginners, is the libbitcoin-explorer command line utility which allows you to explore the full range of bitcoin functions from the command line. This application exposes useful commands for hashing, key generation, transaction creation and submission as well as blockchain querying for balances, height and utxo’s.
Next, Libbitcoin offers a build system in the repository libbitcoin-build. This automated build system installs the entire toolchain from a single script. This option is great for windows or linux users familiar with GSL, travis or automated build systems in general.
Finally, each individual repository can be built with autotools on linux and OSX or with an install script on most platforms. Building libraries individually is useful if you only want to use a specific module of libbitcoin without installing the entire toolchain, though all modules depend on the foundational libbitcoin library.
I will demonstrate installation and building from source of the main libbitcoin library on Mac OSX. This process can be replicated with all other libraries, simply ensure you have installed its specific dependencies before repeating this process. This method is also beneficial if you would like to stay on the bleeding edge of libbitcoin development as it allows you to install the library from a github branch other than the stable realease branch (v3.0).
First, navigate to your working directory and once inside of it, proceed to cloning the libbitcoin repository.
alpha$ git clone https://github.com/libbitcoin/libbitcoin.git
Once the repo is cloned we’re first going to want to switch branches so that we can install the version 3 code. If you would like to install the bleeding edge(and likely, unstable) version of libbitcoin simply build the library using the master branch. First, we’ll need to switch into the local libbitcoin repository with:
alpha$ cd libbitcoin alpha$ git branch --all
This command will display all available remote working branches, to build version 3 we’ll need to check it out first, using the following commands. The second command here creates a local clone of the branch to be worked on:
alpha$ git checkout remotes/origin/version3 alpha$ git checkout -b version3
Now that we have the stable v3 source code, we can install the dependencies. On Mac OSX use:
alpha$ clang++ --version
to make sure your system has LLVM > 6.0. Additionally, OSX users will need to have the Xcode developer tools installed, which can be achieved by invoking:
alpha$ xcode-select --install
Now, in order to install libbitcoin’s other dependencies, brew will need to be used. If you don’t have Homebrew, install it with:
alpha$ ruby "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
Most of the packages libbitcoin relies on can be installed with brew using a single command.
alpha$ brew install autoconf automake libtool pkgconfig wget
Next, a small wrinkle, boost version 1.57 or greater needs to be installed and the current version of boost is 1.63.0. Now, in my personal experience libbitcoin failed to build or compile on OSX, throwing many errors at boost, using the latest version. I’m unaware as to whether or not this bug is on my machine, OSX, or libbitcoin v3 in general; but in order to build libbitcoin I needed to install boost 1.59. This can be achieved in a way very similar to how the latest version of boost is installed, simply append @[1.59] to the brew command.
//alpha$ brew install boost alpha$ brew install firstname.lastname@example.org
Now all of libbitcoin’s dependencies are installed and we are ready to build the library. Now we just need to use autotools to generate the build artifacts and configuration settings.
alpha$ ./autogen.sh alpha$ ./configure
Once those processes are done, make is used to build the library.
alpha$ make alpha$ sudo make install
Boom! Once complete, libbitcoin v3 should be installed on your system. You can test it out by compiling your first libbitcoin program following this tutorial.