4 min read

Building Bitcoin Core v0.7 and Earlier

A guide for how to compile binaries for very old Bitcoin Core versions that are no longer available to download.
Building Bitcoin Core v0.7 and Earlier

Bitcoin Core offers downloads of their software releases dating back to 2013 on their web site. For 99% of users, you should be running the most recent release in order to benefit from the best features, performance, and security.

However, from time to time someone may have a need for running an extremely old release. You may be able to find precompiled binaries from Luke or Matt's web sites, though these mirrors may not be available in the future and in general it's safer to build your own binaries. Note: this should only be done for research purposes; node software that is this old is NOT secure to run for normal use!

I tried simply checking out the Bitcoin Core source code for the v0.7.0 release to see if I could build it myself. Unfortunately, if you try to do this on an up-to-date operating system, the build will fail because it's not compatible with the most recent versions of various code libraries.

Compilation errors when attempting to build v0.7 on a modern Linux OS

So, I figured... perhaps I could run a really old version of Linux inside a virtual machine and build it there? I did come across a project by Brian to build early versions of Bitcoin nodes on Windows, but I'm not a Windows guy. After spending several hours trying different things, I determined that there are two viable methods for building old Bitcoin Core versions on Linux.

Build Method 1: Manual Building

This method is fairly straightforward though it turns out that it's only a good option if you are OK with running Bitcoin Core inside the virtual machine in which you're building the binary. The process is as follows:

  1. Install Virtualbox
  2. Download the Ubuntu 12.04 image.
  3. Create a virtual machine from that image and boot it up. There's a great step-by-step guide here if you're not sure what to do.
  4. Install software dependencies for Bitcoin Core. You can generally find them in the "doc/build-unix.md" file in the code repository.

This is where I hit my first roadblock - I couldn't install anything via apt because all of the repositories return 404 errors!

Err http://archive.ubuntu.com precise/main i386 Packages
 404  Not Found [IP: 80]
Err http://archive.ubuntu.com precise/restricted i386 Packages
 404  Not Found [IP: 80]
Err http://archive.ubuntu.com precise/universe i386 Packages
 404  Not Found [IP: 80]
Err http://archive.ubuntu.com precise/multiverse i386 Packages
 404  Not Found [IP: 80]
Err http://archive.ubuntu.com precise-updates/main i386 Packages
 404  Not Found [IP: 80]

The key to solve this is to change the apt urls from archive.ubuntu.com and security.ubuntu.com to old-releases.ubuntu.com with this command:

sudo sed -i -re 's/([a-z]{2}\.)?archive.ubuntu.com|security.ubuntu.com/old-releases.ubuntu.com/g' /etc/apt/sources.list

Then update:

sudo apt-get update

sudo apt-get install git build-essential libboost-all-dev libdb-dev libdb++-dev libboost-all-dev libminiupnpc-dev

git clone https://github.com/bitcoin/bitcoin.git

cd bitcoin/src/

git checkout v0.7.0 (or whatever version you want to build)

make -f makefile.unix

For releases v0.4 and earlier you'll also need to download a 2.9.x release of wxWidgets, compile, and install it. Basically, you'll want to read the "build-unix.txt" file in the Bitcoin Core source code to figure out what the build dependencies are.

Note that if you need wallet file compatibility, you'll need to manually build and install libdb4.8 rather than using a more modern version.

This is all good and well, and you can run the binary on the virtual machine in which you built it. But what if you want to run it on a different machine with a more up-to-date operating system? You'll be unpleasantly surprised if you try that:

$ ./bitcoind: error while loading shared libraries:
libboost_system.so.1.46.1: cannot open shared object file:
No such file or directory

Oops. Surely there must be a way to build the binaries so that they include all the necessary library code, right?

Build Method 2: Gitian Builder

It takes a bit more work to set up, but gitian allows us to compile binaries that package together all of the library dependencies so that they don't require specific versions of shared libraries to be installed on the machine. Thankfully Andrew Chow has put together this repository with gitian build patches for each of the early versions. Debian users will want to follow the install instructions that can be found here because you may not be able to install all prerequisites via apt.

Personally, I found it far easier to just set it up in an Ubuntu 18.04 virtual machine rather than trying to set up Gitian Builder on a more recent Linux OS version. Don't try using an Ubuntu 12.04 virtual machine like I did for the Build Method 1 instructions or you'll run into issues trying to set up docker.

I followed the following steps to build early versions of Bitcoin Core with gitian:

  1. Install Virtualbox
  2. Download the Ubuntu 18.04 image.
  3. Create a virtual machine from that image and boot it up. There's a great step-by-step guide here if you're not sure what to do. Note: when installing the Ubuntu VM there will be a screen asking you to choose if you want to install any snap packages. Make sure that you select the docker package because it's a requirement for gitian.
  4. Install Gitian Builder dependencies
    sudo apt-get install git apache2 apt-cacher-ng python-vm-builder ruby qemu-utils
  5. git clone https://github.com/devrandom/gitian-builder.git
  6. git clone https://github.com/bitcoin/bitcoin.git
  7. git clone https://github.com/achow101/build-old-bitcoin.git
  8. Follow the build instructions for the version you want to build by finding the relevant README.md in the build-old-bitcoin repository.
  9. Note that for any docker-related commands you'll need to run them with "sudo" first in order to access the docker daemon.

Congratulations, you should now have a bitcoind binary available in gitian-builder/build/out/bin/64/ that you can copy and run on other Linux machines!

I expect that very few people will ever attempt to follow these instructions, but if you do and you run into any issues, fee free to contact me for help.