Skip to content

Instantly share code, notes, and snippets.

@hebasto
Last active March 8, 2024 12:49
Show Gist options
  • Save hebasto/32c77c0cd592d13685437271ac6b79f6 to your computer and use it in GitHub Desktop.
Save hebasto/32c77c0cd592d13685437271ac6b79f6 to your computer and use it in GitHub Desktop.
Building Bitcoin Core with Visual Studio

Building Bitcoin Core with Visual Studio

Introduction

This manual describes building Bitcoin Core with Visual Studio using tools--cmake and vcpkg--provided with the VS installation.

Prerequisites

Building Steps

Open "Developer PowerShell for VS 2022" or "Developer Command Prompt for VS 2022" and run the following commands in it. The following example assumes using the former. The built-in vcpkg is used in the manifest mode. As such, when caches are unpopulated or invalidated cmake -S .. commands might take long time.

Create a dedicated build directory:

mkdir build

It is required once only.

Building with dynamic linking

This scenario uses the x64-windows vcpkg triplet and builds dependencies ~30% faster.

cd build
cmake -S .. --fresh --preset vs2022  # It might take a while if caches are unpopulated or invalidated
cmake --build . -j $env:NUMBER_OF_PROCESSORS --config Release
ctest -j $env:NUMBER_OF_PROCESSORS -C Release

Building with static linking

This scenario uses the x64-windows-static vcpkg triplet.

cd build
cmake -S .. --fresh --preset vs2022-static  # It might take a while if caches are unpopulated or invalidated
cmake --build . -j $env:NUMBER_OF_PROCESSORS --config Release
ctest -j $env:NUMBER_OF_PROCESSORS -C Release
cmake --install . --config Release  # optional

Performance notes

  1. vcpkg builds libraries from source. It might demand significant resources like CPU time, disk space etc, especially, for the qt* packages.

  2. To improve the build process performance, one might add the repository folder to the Microsoft Defender Antivirus exclusions.

Referencies

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment