lbrycrd/build_msvc
Aaron Clauson 4330a1ee7f
Update msvc build for Visual Studio 2019 v16.4
msvc warning C4834 for the Bitcoin Core build was introduced by Visual Studio 16.4.0. This PR adds an ignore rule for the warning (it's related to the nodiscard attribute and is not considered relevant).
An additional side effect of the msvc compiler update is the prebuilt Qt5.9.8 libraries cannot be linked due to being built with an earlier version of the compiler. To fix this a new Qt5.9.8 version has been compiled and the appveyor job updated to use them. The GitHub Actions job needs to continue to use the original Qt5.9.8 libraries until the latest GitHub Windows image also updates to >= Visual Studio 2019 v16.4.

Github-Pull: #17736
Rebased-From: 75d9317bc1aecaab95bf875f8dca97ac3daddff4
2020-01-06 06:35:09 +08:00
..
bench_bitcoin Added the bench_bitcoin project to the list automatically produced by the msvc-autogen python script. 2019-08-29 06:22:06 +02:00
bitcoin-cli [MSVC] Copy build output to src/ automatically after build 2019-07-01 19:16:19 +09:00
bitcoin-qt Updated appveyor config: 2020-01-06 06:30:29 +08:00
bitcoin-tx [MSVC] Copy build output to src/ automatically after build 2019-07-01 19:16:19 +09:00
bitcoin-wallet [MSVC] Copy build output to src/ automatically after build 2019-07-01 19:16:19 +09:00
bitcoind [MSVC] Copy build output to src/ automatically after build 2019-07-01 19:16:19 +09: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_qt Added libbitcoin_qt and bitcoin-qt to the msbuild configuration. 2019-09-08 14:13:05 +02:00
libbitcoin_server [MSVC] Copy build output to src/ automatically after build 2019-07-01 19:16:19 +09:00
libbitcoin_util [MSVC] Copy build output to src/ automatically after build 2019-07-01 19:16:19 +09:00
libbitcoin_wallet [MSVC] Copy build output to src/ automatically after build 2019-07-01 19:16:19 +09: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 [MSVC] Copy build output to src/ automatically after build 2019-07-01 19:16:19 +09:00
libsecp256k1 [MSVC] Copy build output to src/ automatically after build 2019-07-01 19:16:19 +09: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 Updated appveyor config: 2020-01-06 06:30:29 +08:00
test_bitcoin-qt Added libbitcoin_qt and bitcoin-qt to the msbuild configuration. 2019-09-08 14:13:05 +02:00
testconsensus [MSVC] Copy build output to src/ automatically after build 2019-07-01 19:16:19 +09:00
.gitignore Added libbitcoin_qt and bitcoin-qt to the msbuild configuration. 2019-09-08 14:13:05 +02:00
bitcoin.sln Added libbitcoin_qt and bitcoin-qt to the msbuild configuration. 2019-09-08 14:13:05 +02:00
bitcoin_config.h build: bump version to 0.19.0.1 2019-11-14 20:35:23 +01:00
common.init.vcxproj Update msvc build for Visual Studio 2019 v16.4 2020-01-06 06:35:09 +08:00
common.qt.init.vcxproj Updated appveyor config: 2020-01-06 06:30:29 +08:00
common.vcxproj [MSVC] Copy build output to src/ automatically after build 2019-07-01 19:16:19 +09:00
libsecp256k1_config.h msvc: build secp256k1 locally 2019-02-01 00:28:49 +08:00
msvc-autogen.py Added the bench_bitcoin project to the list automatically produced by the msvc-autogen python script. 2019-08-29 06:22:06 +02:00
README.md Moves vcpkg list to a text file and updates the appveyor job and readme to use it. 2020-01-06 06:34:33 +08:00
vcpkg-packages.txt Moves vcpkg list to a text file and updates the appveyor job and readme to use it. 2020-01-06 06:34:33 +08:00

Building Bitcoin Core with Visual Studio

Introduction

Solution and project files to build the Bitcoin Core applications msbuild or Visual Studio can be found in the build_msvc directory. The build has been tested with Visual Studio 2017 and 2019.

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

Quick Start

The minimal steps required to build Bitcoin Core with the msbuild toolchain are below. More detailed instructions are contained in the following sections.

vcpkg install --triplet x64-windows-static boost-filesystem boost-signals2 boost-test libevent openssl zeromq berkeleydb rapidcheck double-conversion
py -3 build_msvc\msvc-autogen.py
msbuild /m build_msvc\bitcoin.sln /p:Platform=x64 /p:Configuration=Release /t:build

Dependencies

A number of open source libraries are required in order to be able to build Bitcoin Core.

Options for installing the dependencies in a Visual Studio compatible manner are:

  • Use Microsoft's vcpkg to download the source packages and build locally. This is the recommended approach.
  • Download the source code, build each dependency, add the required include paths, link libraries and binary tools to the Visual Studio project files.
  • Use nuget packages with the understanding that any binary files have been compiled by an untrusted third party.

The external dependencies required for building are:

  • Berkeley DB
  • Boost
  • DoubleConversion
  • libevent
  • OpenSSL
  • Qt5
  • RapidCheck
  • ZeroMQ

Qt

All the Bitcoin Core applications are configured to build with static linking. In order to build the Bitcoin Core Qt applications a static build of Qt is required.

The runtime library version (e.g. v141, v142) and platform type (x86 or x64) must also match. OpenSSL must also be linked into the Qt binaries in order to provide full functionality of the Bitcoin Core Qt programs. An example of the configure command to build Qtv5.9.7 locally to link with Bitcoin Core is shown below (adjust paths accordingly), note it can be expected that the configure and subsequent build will fail numerous times until dependency issues are resolved.

..\Qtv5.9.7_src\configure -developer-build -confirm-license -debug-and-release -opensource -platform win32-msvc -opengl desktop -no-shared -static -no-static-runtime -mp -qt-zlib -qt-pcre -qt-libpng -ltcg -make libs -make tools -no-libjpeg -nomake examples -no-compile-examples -no-dbus -no-libudev -no-qml-debug -no-icu -no-gtk -no-opengles3 -no-angle -no-sql-sqlite -no-sql-odbc -no-sqlite -no-libudev -skip qt3d -skip qtactiveqt -skip qtandroidextras -skip qtcanvas3d -skip qtcharts -skip qtconnectivity -skip qtdatavis3d -skip qtdeclarative -skip qtdoc -skip qtgamepad -skip qtgraphicaleffects -skip qtimageformats -skip qtlocation -skip qtmacextras -skip qtmultimedia -skip qtnetworkauth -skip qtpurchasing -skip qtquickcontrols -skip qtquickcontrols2 -skip qtscript -skip qtscxml -skip qtsensors -skip qtserialbus -skip qtserialport -skip qtspeech -skip qtvirtualkeyboard -skip qtwayland -skip qtwebchannel -skip qtwebengine -skip qtwebsockets -skip qtwebview -skip qtx11extras -skip qtxmlpatterns -nomake tests -openssl-linked -IC:\Dev\github\vcpkg\installed\x64-windows-static\include -LC:\Dev\github\vcpkg\installed\x64-windows-static\lib OPENSSL_LIBS="-llibeay32 -lssleay32 -lgdi32 -luser32 -lwsock32 -ladvapi32" -prefix C:\Qt5.9.7_ssl_x64_static_vs2017

A prebuilt version for x64 and Visual C++ runtime v141 (Visual Studio 2017) can be downloaded from here. Please be aware this download is NOT an officially sanctioned Bitcoin Core distribution and is provided for developer convenience. It should NOT be used for builds that will be used in a production environment or with real funds.

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

Building

The instructions below use vcpkg to install the dependencies.

  • Install vcpkg.
  • Install the required packages (replace x64 with x86 as required). The list of required packages can be found in the build_msvc\vcpkg-packages.txt file. The PowerShell command below will work if run from the repository root directory and vcpkg is in the path. Alternatively the contents of the packages text file can be pasted in place of the Get-Content cmdlet.
PS >.\vcpkg install --triplet x64-windows-static $(Get-Content -Path build_msvc\vcpkg-packages.txt).split()

  • Use Python to generate *.vcxproj from Makefile
    PS >py -3 msvc-autogen.py
  • 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.

  • Build with Visual Studio 2017 or msbuild.

msbuild /m bitcoin.sln /p:Platform=x64 /p:Configuration=Release /p:PlatformToolset=v141 /t:build
  • Build with Visual Studio 2019 or msbuild.
msbuild /m bitcoin.sln /p:Platform=x64 /p:Configuration=Release /t:build

AppVeyor

The .appveyor.yml in the root directory is suitable to perform builds on AppVeyor Continuous Integration servers. The simplest way to perform an AppVeyor build is to fork Bitcoin Core and then configure a new AppVeyor Project pointing to the forked repository.

For safety reasons the Bitcoin Core .appveyor.yml file has the artifact options disabled. The build will be performed but no executable files will be available. To enable artifacts on a forked repository uncomment the lines shown below:

    #- 7z a bitcoin-%APPVEYOR_BUILD_VERSION%.zip %APPVEYOR_BUILD_FOLDER%\build_msvc\%platform%\%configuration%\*.exe
    #- path: bitcoin-%APPVEYOR_BUILD_VERSION%.zip