How to compile Bitcoin core on Windows 10 PC — Updated

sunny okoro
6 min readAug 3, 2022

--

I had intially written about this before so you may ask why then are you doing this all over again, the simple reason is this, my previous setup was targeting Ubuntu 18,04 distribution where as the latest as of the time of writting was v22.04 so expecting some of the issues I encountered in my previous setup to have been resolved. I went the route of Uninstalling Ubuntu on my PC going through the Program files as shown below and re-installing all over through the Windows Store on Windows 10, however this time using v22.04.

This works for Win 10 PCs. To confirm your OS version, run the ver command on command prompt.

Confirm Windows Version

WSL — Windows System for Linux, a software that allows you run Linux on Windows.

Any build lower than 18917 is running on WSL 1 so you but build above is on WSL 2.

For build below, follow these steps outlined in the url to upgrade from WSL 1 to WSL 2

Confirm WSL version on windows

Uninstalling Ubuntu

Uninstall Ubuntu

Re-Installing Ubuntu

installing Ubuntu 22,04 distribution

Upon re-installation of the Ubuntu and attempting to re-compile Bitcoin Core (v22.0), I realized it was failing, I attempted over 4 times with the same error only to find out that I needed to upgrade my WSL from WSL1 to WSL2. This I did and restarted my device and the setup was successfully complete.

Image showing successful installation of Ubuntu

In this article, I will walk you through the steps in achieving this so you don’t need to experience the same hassle I had.

After installation, setup your username and password. The next steps will walk us through how to setup git on the OS. The steps are;

Installing git

>> sudo apt update

>> sudo apt install git

>> git — version

cmd to know your git version

Installing Bitcoin

1. Create the bitcoin directory using

mkdir 'foldername'

2. Enter the directory

cd bitcoincore

3. Clone the bitcoin repository

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

4. Checkout to v22.0, this is because at the time of writting this article, I was unable dumpprivkey which is used to get the privatekeys of a bitcoin address which is required to sign bitcoin trans. You may choose to use the latest branch or choose a branch of your choice.
a. To list all the branches

git tag

b. Checkout to your preferred

git checkout v22.0

5. Locate the src folder and identify the readme file for your OS distribution, in our case unix as shown below and use the less command to open the file on read-only mode.

less build-unix.md
the red me file
Open the build file on read-only mode.

6. Identify the section of the read me file that has to do with your OS version and follow the steps to install the packages/dependences needed to compile Bitcoin core from source code.

Inorder to compile Bitcoin from source codes, the most essencial commands are, however there are some dependencies that must be installed before these commands are successfully executed.

./autogen.sh
./configure
make # use "-j N" for N parallel jobs
make install # optional

Installing dependencies: These are the dependencies that must be installed before the cmds above are ran.

NOTE: The below commands should be ran inside the cloned director, in my case as below

bitcoin cloned git directory

Build requirements:

sudo apt-get install build-essential libtool autotools-dev automake pkg-config bsdmainutils python3

Now, you can either build from self-compiled depends or install the required dependencies:

sudo apt-get install libevent-dev libboost-dev

SQLite is required for the descriptor wallet:

sudo apt install libsqlite3-dev

Plug and Play software

sudo apt install libminiupnpc-dev libnatpmp-dev

ZMQ dependencies (provides ZMQ API):

sudo apt-get install libzmq3-dev

User-Space, Statically Defined Tracing (USDT) dependencies:

sudo apt install systemtap-sdt-dev

libqrencode (optional) can be installed with:

sudo apt-get install libqrencode-dev

After above is done, you will need to properly install the Berkeley DB

./contrib/install_db4.sh .

Run the autogen command which is inside the bitcoin directory as below. This command will return 2 results which will be used to configure the Berkeley DB to take note of them.

Sample result of the db cmd above. This will be used later in the course of the setup.

export BDB_PREFIX=’/home/sunfarms/bitcoincore/bitcoin/db4'./configure BDB_LIBS=”-L${BDB_PREFIX}/lib -ldb_cxx-4.8" BDB_CFLAGS=”-I${BDB_PREFIX}/include”

Let’s start building the bitcoin core.

./autogen.sh

Run the configure command from the bitcoin cloned directry

run ./configure cmd
./configure

The configure command may return an error which has to do dissabling db wallet. If this is shown, run the commands to configure the db path.

export BDB_PREFIX=’/home/sunfarms/bitcoincore/bitcoin/db4'./configure BDB_LIBS=”-L${BDB_PREFIX}/lib -ldb_cxx-4.8" BDB_CFLAGS=”-I${BDB_PREFIX}/include”

See the error shown after the configure command is run

After the above, run the configure command again. It should be successful this time.

./configure BDB_LIBS=”-L${BDB_PREFIX}/lib -ldb_cxx-4.8" BDB_CFLAGS=”-I${BDB_PREFIX}/include”

I had this error below in the course of running ./configure BDB_LIBS=”-L${BDB_PREFIX}/lib -ldb_cxx-4.8" BDB_CFLAGS=”-I${BDB_PREFIX}/include”

https://stackoverflow.com/questions/53089494/configure-error-could-not-find-a-version-of-the-library

I ran the cmd sudo apt-get install libboost-all-dev and after that, I ran the configure cmd and that was it after which you run the configure command.

sudo apt-get install libboost-all-dev

Run the configure command again

./configure BDB_LIBS=”-L${BDB_PREFIX}/lib -ldb_cxx-4.8" BDB_CFLAGS=”-I${BDB_PREFIX}/include”

Run the make command once the configure cmd shows promise of being successful. The make command is what does the compillation.

make

Execute the make install which configures the bitcoind and bitcoin-cli on the system’s envvironment so you can execute the bitcoin cmd from any directory.

make install

Note: If you have permission issue executing the make install command, add sudo to it as below

sudo make install

To confirm successful execution, run the bitcoin daemon as below.

Once started, your bitcoin node will start downloading the full bitcoin blockchain with is over 400GB at the time of writing this, to change the configuration, create the bitcoin.conf file. You may need to create it if yet available. this file is found in the .bitcoin directory in the root.

creating the bitcoin.conf file
ls -a

In the root directory, the command ls -a lists all folders (hidden folders and files includsive).

touch bitcoin.conf

NOTE: The .bitcoind directory on the root will not be created until you have started your daemon.

Also note that the bitcoin-cli command will not be automatically recognized, you will need to add the command to your bash .profile to be recognized from any directory you may be which is what make install achieves

Congratulations, you have successfully compiled bitcoin core from source code.

Resources:

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

--

--

sunny okoro

Software Tech Lead | Solutions Architect | Father | Farmer | Jesus lover | #Fintech | @Umbrel Full Node runner | DevOps | #BitcoinCoding