For a piece of code to be used in a program, the source code has to be built. Building is the process of converting source code into an executable, which in turn can be run by a user.
Bitcoin Core can be built for different platforms such as Windows, MacOS, Unix and many other more. Each platform has its own processes to build the code and there is a lot of documentation in the Bitcoin Core repository that highlights the procedures to follow1 .
In this post, we will cover the building using Microsoft Visual Studio and its compiler msvc2.
Dependencies
The first thing to do in order to be able to build Bitcoin Core is to install the dependencies on which it is based. We call dependencies those already-existing libraries on which a code depends on.
To do so, Bitcoin Core developers suggest to use Vcpkg3, a library management software that allows a user to easily download the required libraries.
Some of the dependencies on which Bitcoin Core runs are Boost4, an open-source C++ library that expands the standard library, libevent5, an event notification library, glib and Linux kernel, that allows to use Linux as a kernel.
Finally, Bitcoin Core could also be built with a Graphical User Interface (GUI); to do so, Qt libraries6 should be installed. However, it is not mandatory to build the code with a GUI, thus these dependencies may be avoided.
Preparing the solution
Once the dependencies have been installed, it is possible to create the project. A Visual Studio solution comes with a .sln file that contains the overall project with its dependencies and settings.
Before starting the build, we need to launch a python script to create the .vcxproj file, which contains the settings for the project used by the VS solution.
As soon as the .vcxproj is ready, it is finally possible to launch the Bitcoin Core build.
Building Bitcoin Core
Once the overall project structure is ready, the last thing to do is to actually launch the building process. The compiler will take the previously created settings file, all the dependencies and create the executable.
The message “Build Succeded” will signal that the build was successfully completed.
Congratulations!!
Enough for today!
If you know anyone who might be interested in this newsletter, consider sharing it with him/her.
See you next week with a new episode of Inside Bitcoin Code!
You are laying a great foundation!