dogecoin/build_msvc
Wladimir J. van der Laan 7a311fa54a
Merge #17738: build: remove linking librt for backwards compatibility
f7453dcc03 build: remove linking librt for backwards compatibility (fanquake)

Pull request description:

  Now that we require glibc 2.17+, see #17538, we can remove linking librt
  for backwards compatibility purposes. The `clock_*` functions from librt
  were merged into glibc as part of the [2.17 release](https://sourceware.org/ml/libc-announce/2012/msg00001.html):

  * The `clock_*` suite of functions (declared in <time.h>) is now available
    directly in the main C library.  Previously it was necessary to link with
    -lrt to use these functions.  This change has the effect that a
    single-threaded program that uses a function such as `clock_gettime' (and
    is not linked with -lrt) will no longer implicitly load the pthreads
    library at runtime and so will not suffer the overheads associated with
    multi-thread support in other code such as the C++ runtime library.

  Note that `librt` is already unused by the RISC-V and AARCH64 binaries as their librts don't export any `clock_*` functions. As an example, you can find a diff of the arm32 vs arm64 librt symbols [here](https://gist.github.com/fanquake/b08cb1f0d14df3133395d7796ebf030c).

  Below is the library usage for the `v0.19.0.1` release (can delete these tables pre-merge).

  #### RISC-V
  ```bash
  riscv/bin/bitcoin-cli: ['libpthread.so.0', 'libm.so.6', 'libgcc_s.so.1', 'libc.so.6', 'ld-linux-riscv64-lp64d.so.1']
  riscv/bin/bitcoin-qt: ['libpthread.so.0', 'libfontconfig.so.1', 'libfreetype.so.6', 'libxcb.so.1', 'libdl.so.2', 'libm.so.6', 'libgcc_s.so.1', 'libc.so.6', 'ld-linux-riscv64-lp64d.so.1', 'libatomic.so.1']
  riscv/bin/bitcoin-wallet: ['libpthread.so.0', 'libm.so.6', 'libgcc_s.so.1', 'libc.so.6', 'ld-linux-riscv64-lp64d.so.1', 'libatomic.so.1']
  riscv/bin/bitcoind: ['libpthread.so.0', 'libm.so.6', 'libgcc_s.so.1', 'libc.so.6', 'ld-linux-riscv64-lp64d.so.1', 'libatomic.so.1']
  riscv/bin/bitcoin-tx: ['libpthread.so.0', 'libm.so.6', 'libgcc_s.so.1', 'libc.so.6', 'ld-linux-riscv64-lp64d.so.1']
  riscv/bin/test_bitcoin: ['libpthread.so.0', 'libm.so.6', 'libgcc_s.so.1', 'libc.so.6', 'ld-linux-riscv64-lp64d.so.1', 'libatomic.so.1']
  ```

  #### AARCH64
  ```bash
  aarch64/bin/bitcoin-cli: ['libpthread.so.0', 'libm.so.6', 'libgcc_s.so.1', 'libc.so.6', 'ld-linux-aarch64.so.1']
  aarch64/bin/bitcoin-qt: ['libpthread.so.0', 'libfontconfig.so.1', 'libfreetype.so.6', 'libxcb.so.1', 'libdl.so.2', 'libm.so.6', 'libgcc_s.so.1', 'libc.so.6', 'ld-linux-aarch64.so.1']
  aarch64/bin/bitcoin-wallet: ['libpthread.so.0', 'libm.so.6', 'libgcc_s.so.1', 'libc.so.6', 'ld-linux-aarch64.so.1']
  aarch64/bin/bitcoind: ['libpthread.so.0', 'libm.so.6', 'libgcc_s.so.1', 'libc.so.6', 'ld-linux-aarch64.so.1']
  aarch64/bin/bitcoin-tx: ['libpthread.so.0', 'libm.so.6', 'libgcc_s.so.1', 'libc.so.6', 'ld-linux-aarch64.so.1']
  aarch64/bin/test_bitcoin: ['libpthread.so.0', 'libm.so.6', 'libgcc_s.so.1', 'libc.so.6', 'ld-linux-aarch64.so.1']
  ```

  #### ARM LINUX GNUEABIHF
  ```bash
  arm32/bin/bitcoin-cli: ['libpthread.so.0', 'librt.so.1', 'libm.so.6', 'libgcc_s.so.1', 'libc.so.6', 'ld-linux-armhf.so.3']
  arm32/bin/bitcoin-qt: ['libpthread.so.0', 'librt.so.1', 'libfontconfig.so.1', 'libfreetype.so.6', 'libxcb.so.1', 'libdl.so.2', 'libm.so.6', 'libgcc_s.so.1', 'libc.so.6', 'ld-linux-armhf.so.3']
  arm32/bin/bitcoin-wallet: ['libpthread.so.0', 'librt.so.1', 'libm.so.6', 'libgcc_s.so.1', 'libc.so.6', 'ld-linux-armhf.so.3']
  arm32/bin/bitcoind: ['libpthread.so.0', 'librt.so.1', 'libm.so.6', 'libgcc_s.so.1', 'libc.so.6', 'ld-linux-armhf.so.3']
  arm32/bin/bitcoin-tx: ['libpthread.so.0', 'librt.so.1', 'libm.so.6', 'libgcc_s.so.1', 'libc.so.6', 'ld-linux-armhf.so.3']
  arm32/bin/test_bitcoin: ['libpthread.so.0', 'librt.so.1', 'libm.so.6', 'libgcc_s.so.1', 'libc.so.6', 'ld-linux-armhf.so.3']
  ```

  #### LINUX X86_64
  ```bash
  x86_64/bin/bitcoin-cli: ['libpthread.so.0', 'librt.so.1', 'libm.so.6', 'libgcc_s.so.1', 'libc.so.6', 'ld-linux-x86-64.so.2']
  x86_64/bin/bitcoin-qt: ['libpthread.so.0', 'librt.so.1', 'libfontconfig.so.1', 'libfreetype.so.6', 'libxcb.so.1', 'libdl.so.2', 'libm.so.6', 'libgcc_s.so.1', 'libc.so.6', 'ld-linux-x86-64.so.2']
  x86_64/bin/bitcoin-wallet: ['libpthread.so.0', 'librt.so.1', 'libm.so.6', 'libgcc_s.so.1', 'libc.so.6', 'ld-linux-x86-64.so.2']
  x86_64/bin/bitcoind: ['libpthread.so.0', 'librt.so.1', 'libm.so.6', 'libgcc_s.so.1', 'libc.so.6', 'ld-linux-x86-64.so.2']
  x86_64/bin/bitcoin-tx: ['libpthread.so.0', 'librt.so.1', 'libm.so.6', 'libgcc_s.so.1', 'libc.so.6', 'ld-linux-x86-64.so.2']
  x86_64/bin/test_bitcoin: ['libpthread.so.0', 'librt.so.1', 'libm.so.6', 'libgcc_s.so.1', 'libc.so.6', 'ld-linux-x86-64.so.2']
  ```

  #### LINUX i686
  ```bash
  i686/bin/bitcoin-cli: ['libpthread.so.0', 'librt.so.1', 'libm.so.6', 'libgcc_s.so.1', 'libc.so.6', 'ld-linux.so.2']
  i686/bin/bitcoin-qt: ['libpthread.so.0', 'librt.so.1', 'libfontconfig.so.1', 'libfreetype.so.6', 'libxcb.so.1', 'libdl.so.2', 'libm.so.6', 'libgcc_s.so.1', 'libc.so.6', 'ld-linux.so.2']
  i686/bin/bitcoin-wallet: ['libpthread.so.0', 'librt.so.1', 'libm.so.6', 'libgcc_s.so.1', 'libc.so.6', 'ld-linux.so.2']
  i686/bin/bitcoind: ['libpthread.so.0', 'librt.so.1', 'libm.so.6', 'libgcc_s.so.1', 'libc.so.6', 'ld-linux.so.2']
  i686/bin/bitcoin-tx: ['libpthread.so.0', 'librt.so.1', 'libm.so.6', 'libgcc_s.so.1', 'libc.so.6', 'ld-linux.so.2']
  i686/bin/test_bitcoin: ['libpthread.so.0', 'librt.so.1', 'libm.so.6', 'libgcc_s.so.1', 'libc.so.6', 'ld-linux.so.2']
  ```

ACKs for top commit:
  laanwj:
    ACK f7453dcc03

Tree-SHA512: b418260edcda88583abfa386a592ebfb977d111e8e2ba887a30bf830b0b10dba429b9cfd615fad453ff0bb824225914ccb91433064b158ae1fbb9d20fc0b9937
2020-01-22 22:24:51 +01:00
..
bench_bitcoin Added libtest_util library to msvc build configuration. 2019-11-23 15:49:16 +00:00
bitcoin-cli [MSVC] Copy build output to src/ automatically after build 2019-07-01 19:16:19 +09:00
bitcoin-qt Ignore msvc linker warning and update to msvc build instructions. 2020-01-09 09:19:36 +00: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
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 Added libtest_util library to msvc build configuration. 2019-11-23 15:49:16 +00:00
test_bitcoin-qt Ignore msvc linker warning and update to msvc build instructions. 2020-01-09 09:19:36 +00:00
testconsensus scripted-diff: Add missed copyright headers 2020-01-04 20:18:28 +02:00
.gitignore Added libbitcoin_qt and bitcoin-qt to the msbuild configuration. 2019-09-08 14:13:05 +02:00
bitcoin.sln Included test_bitcoin-qt in msvc build. 2019-12-13 12:07:32 +00:00
bitcoin_config.h Merge #17738: build: remove linking librt for backwards compatibility 2020-01-22 22:24:51 +01:00
common.init.vcxproj Ignore msvc linker warning and update to msvc build instructions. 2020-01-09 09:19:36 +00:00
common.qt.init.vcxproj Updated appveyor config: 2019-11-06 22:02:16 +00: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 scripted-diff: Add missed copyright headers 2020-01-04 20:18:28 +02:00
README.md Ignore msvc linker warning and update to msvc build instructions. 2020-01-09 09:19:36 +00:00
vcpkg-packages.txt Appveyor install libevent[thread] vcpkg 2019-11-25 13:35:36 +00: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 berkeleydb boost-filesystem boost-multi-index boost-signals2 boost-test boost-thread libevent[thread] rapidcheck zeromq 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
  • Qt5
  • RapidCheck
  • ZeroMQ

Qt

In order to build the Bitcoin Core a static build of Qt is required. The runtime library version (e.g. v141, v142) and platform type (x86 or x64) must also match.

Some prebuilt x64 versions of Qt can be downloaded from here. Please be aware these downloads are NOT officially sanctioned by Bitcoin Core and are provided for developer convenience only. They should NOT be used for builds that will be used in a production environment or with real funds.

To determine which Qt prebuilt version to download open the .appveyor.yml file and note the QT_DOWNLOAD_URL. When extracting the zip file the destination path must be set to C:\. This is due to the way that Qt includes, libraries and tools use internal paths.

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.

  • To build from the command line with the Visual Studio 2017 toolchain use:

msbuild /m bitcoin.sln /p:Platform=x64 /p:Configuration=Release /p:PlatformToolset=v141 /t:build
  • To build from the command line with the Visual Studio 2019 toolchain use:
msbuild /m bitcoin.sln /p:Platform=x64 /p:Configuration=Release /t:build
  • Alternatively open the build_msvc\bitcoin.sln file in Visual Studio.

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