bitcoin/build_msvc
MarcoFalke ddcc518cbd
Merge bitcoin/bitcoin#23828: scripted-diff: Rename libbitcoin_server.a to libbitcoin_node.a
172096e9dd scripted-diff: Rename libbitcoin_server.a to libbitcoin_node.a (Russell Yanofsky)

Pull request description:

  Goal along with namespacing PR #23497 is to make code organization more obvious and have `src/node/` code in `node::` namespace in `libbitcoin_node.a` library

ACKs for top commit:
  MarcoFalke:
    cr ACK 172096e9dd

Tree-SHA512: a2e787eeaa3ab769b0f5376473072cae584d237aa8b67b677bea833bb36b0134a0eca17eb01722389639473b8463f4953bc3a5e4801a6b2c8965ac1075cba005
2022-01-06 14:59:17 +01:00
..
bench_bitcoin scripted-diff: Rename libbitcoin_server.a to libbitcoin_node.a 2021-12-20 10:53:01 -05:00
bitcoin-cli [MSVC] Copy build output to src/ automatically after build 2019-07-01 19:16:19 +09:00
bitcoin-qt scripted-diff: Rename libbitcoin_server.a to libbitcoin_node.a 2021-12-20 10:53:01 -05:00
bitcoin-tx [MSVC] Copy build output to src/ automatically after build 2019-07-01 19:16:19 +09:00
bitcoin-util build_msvc: Make bitcoin-util ProjectGuid unique 2021-09-08 11:58:03 +03:00
bitcoin-wallet build: Drop unneeded dependencies for bitcoin-wallet tool 2021-11-13 21:24:51 +02:00
bitcoind scripted-diff: Rename libbitcoin_server.a to libbitcoin_node.a 2021-12-20 10:53:01 -05:00
libbitcoin_cli [MSVC] Copy build output to src/ automatically after build 2019-07-01 19:16:19 +09:00
libbitcoin_common [MSVC] Copy build output to src/ automatically after build 2019-07-01 19:16:19 +09:00
libbitcoin_crypto [MSVC] Copy build output to src/ automatically after build 2019-07-01 19:16:19 +09:00
libbitcoin_node scripted-diff: Rename libbitcoin_server.a to libbitcoin_node.a 2021-12-20 10:53:01 -05:00
libbitcoin_qt build_msvc: Drop 32-bit build configurations 2021-09-08 11:58:12 +03:00
libbitcoin_util Drop unintended bitcoin-tx dependency on libevent 2020-04-02 08:28:11 -04:00
libbitcoin_wallet Do not compile BDB things when USE_BDB is defined 2020-11-18 11:56:08 -05:00
libbitcoin_wallet_tool [MSVC] Copy build output to src/ automatically after build 2019-07-01 19:16:19 +09:00
libbitcoin_zmq [MSVC] Copy build output to src/ automatically after build 2019-07-01 19:16:19 +09:00
libbitcoinconsensus [MSVC] Copy build output to src/ automatically after build 2019-07-01 19:16:19 +09:00
libleveldb build: Enable safe warnings for msvc builds 2021-03-29 11:01:19 +03:00
libminisketch Add MSVC build configuration for libminisketch 2021-10-21 09:38:45 +08:00
libsecp256k1 Disable certain false positive warnings for libsecp256k1 msvc build 2021-04-02 13:17:49 -07:00
libtest_util Added libtest_util library to msvc build configuration. 2019-11-23 15:49:16 +00:00
libunivalue [MSVC] Copy build output to src/ automatically after build 2019-07-01 19:16:19 +09:00
msbuild/tasks [MSVC]: Create the config.ini as part of bitcoind build 2019-06-21 16:23:35 +09:00
test_bitcoin scripted-diff: Rename libbitcoin_server.a to libbitcoin_node.a 2021-12-20 10:53:01 -05:00
test_bitcoin-qt scripted-diff: Rename libbitcoin_server.a to libbitcoin_node.a 2021-12-20 10:53:01 -05:00
.gitignore scripted-diff: Rename libbitcoin_server.a to libbitcoin_node.a 2021-12-20 10:53:01 -05:00
bitcoin_config.h.in build_msvc/bitcoin_config.h is generated using build_msvc/msvc-autogen.py 2021-11-14 15:00:29 +01:00
bitcoin.sln scripted-diff: Rename libbitcoin_server.a to libbitcoin_node.a 2021-12-20 10:53:01 -05:00
common.init.vcxproj Add MSVC build configuration for libminisketch 2021-10-21 09:38:45 +08:00
common.qt.init.vcxproj build: Make <QtBaseDir> default name Qt and VS versions agnostic 2021-09-07 22:25:38 +03:00
common.vcxproj Adjusted msvc compiler and linker settings to remove optimisations that are causing sporadic ABI issues on Visual Studio updates. 2020-12-02 11:39:01 +00:00
libsecp256k1_config.h doc: Fix typos in endif header comments 2021-11-16 09:56:45 +01:00
msvc-autogen.py Merge bitcoin/bitcoin#23828: scripted-diff: Rename libbitcoin_server.a to libbitcoin_node.a 2022-01-06 14:59:17 +01:00
README.md doc: Update build_msvc/README.md for Qt 5.15.2 2021-12-03 14:07:12 +08:00
vcpkg.json ci: remove boost thread installation 2021-02-02 12:38:22 +08:00

Building Bitcoin Core with Visual Studio

Introduction

Solution and project files to build Bitcoin Core with msbuild or Visual Studio can be found in the build_msvc directory. The build has been tested with Visual Studio 2019 (building with earlier versions of Visual Studio should not be expected to work).

To build Bitcoin Core from the command-line, it is sufficient to only install the Visual Studio Build Tools component.

Building with Visual Studio is an alternative to the Linux based cross-compiler build.

Prerequisites

To build dependencies (except for Qt), the default approach is to use the vcpkg package manager from Microsoft:

  1. Install vcpkg.

  2. By default, vcpkg makes both release and debug builds for each package. To save build time and disk space, one could skip debug builds (example uses PowerShell):


Add-Content -Path "vcpkg\triplets\x64-windows-static.cmake" -Value "set(VCPKG_BUILD_TYPE release)"

Qt

To build Bitcoin Core with the GUI, a static build of Qt is required.

  1. Download a single ZIP archive of Qt source code from https://download.qt.io/official_releases/qt/ (e.g., qt-everywhere-src-5.15.2.zip), and expand it into a dedicated folder. The following instructions assume that this folder is C:\dev\qt-source.

  2. Open "x64 Native Tools Command Prompt for VS 2019", and input the following commands:

cd C:\dev\qt-source
mkdir build
cd build
..\configure -release -silent -opensource -confirm-license -opengl desktop -static -static-runtime -mp -qt-zlib -qt-pcre -qt-libpng -nomake examples -nomake tests -nomake tools -no-angle -no-dbus -no-gif -no-gtk -no-ico -no-icu -no-libjpeg -no-libudev -no-sql-sqlite -no-sql-odbc -no-sqlite -no-vulkan -skip qt3d -skip qtactiveqt -skip qtandroidextras -skip qtcharts -skip qtconnectivity -skip qtdatavis3d -skip qtdeclarative -skip doc -skip qtdoc -skip qtgamepad -skip qtgraphicaleffects -skip qtimageformats -skip qtlocation -skip qtlottie -skip qtmacextras -skip qtmultimedia -skip qtnetworkauth -skip qtpurchasing -skip qtquick3d -skip qtquickcontrols -skip qtquickcontrols2 -skip qtquicktimeline -skip qtremoteobjects -skip qtscript -skip qtscxml -skip qtsensors -skip qtserialbus -skip qtserialport -skip qtspeech -skip qtsvg -skip qtvirtualkeyboard -skip qtwayland -skip qtwebchannel -skip qtwebengine -skip qtwebglplugin -skip qtwebsockets -skip qtwebview -skip qtx11extras -skip qtxmlpatterns -no-openssl -no-feature-bearermanagement -no-feature-printdialog -no-feature-printer -no-feature-printpreviewdialog -no-feature-printpreviewwidget -no-feature-sql -no-feature-sqlmodel -no-feature-textbrowser -no-feature-textmarkdownwriter -no-feature-textodfwriter -no-feature-xml -prefix C:\Qt_static
nmake
nmake install

One could speed up building with jom, a replacement for nmake which makes use of all CPU cores.

To build Bitcoin Core without Qt, unload or disable the bitcoin-qt, libbitcoin_qt and test_bitcoin-qt projects.

Building

  1. Use Python to generate *.vcxproj from Makefile:
PS >py -3 msvc-autogen.py
  1. An optional step is to adjust the settings in the build_msvc directory and the common.init.vcxproj file. This project file contains settings that are common to all projects such as the runtime library version and target Windows SDK version. The Qt directories can also be set. To specify a non-default path to a static Qt package directory, use the QTBASEDIR environment variable.

  2. To build from the command-line with the Visual Studio 2019 toolchain use:

msbuild -property:Configuration=Release -maxCpuCount -verbosity:minimal bitcoin.sln

Alternatively, open the build_msvc/bitcoin.sln file in Visual Studio 2019.

Security

Base address randomization is used to make Bitcoin Core more secure. When building Bitcoin using the build_msvc process base address randomization can be disabled by editing common.init.vcproj to change RandomizedBaseAddress from true to false and then rebuilding the project.

To check if bitcoind has RandomizedBaseAddress enabled or disabled run

.\dumpbin.exe /headers src/bitcoind.exe

If is it enabled then in the output Dynamic base will be listed in the DLL characteristics under OPTIONAL HEADER VALUES as shown below

            8160 DLL characteristics
                   High Entropy Virtual Addresses
                   Dynamic base
                   NX compatible
                   Terminal Server Aware

This may not disable all stack randomization as versions of windows employ additional stack randomization protections. These protections must be turned off in the OS configuration.