Skip to content

Commit 7fbf3c6

Browse files
committed
Merge #11438: Updated Windows build doc for WSL/Xenial workaround
7383d77 Updated instructions for Windows 10 Fall Creators Update. (Aaron Clauson) e0fc4a7 Updated Windows build doc for WSL/Xenial workarounds. (Aaron Clauson) Pull request description: An update to the Windows build document that provides workarounds for the broken 64 bit mingw32 cross compiler on WSL/Xenial. This update is an alternative to pull request #11437. While that pull request takes a valid approach by stating building on WSL should be avoided I think it is more useful to give Windows developers a workaround option. The instructions have been tested on: - Ubuntu 14.04 and 64 bit mingw32 tool chain - Ubuntu 16.04 and 64 bit mingw32 tool chain - Ubuntu 17.04 and 64 bit mingw32 tool chain - Windows Subsystem for Linux (Windows 10 OS Build 15063.608) and 32 bit mingw32 tool chain - Windows Subsystem for Linux (Windows 10 OS Build 15063.608) and 64 bit mingw32 tool chain Related items: - Serious incompatibility problems w/ newer mingw-64 on Ubuntu #8653 - `-fstack-protector-all` triggers crashes in mingw-w64 5.3.1 #8732 - Windows build appears broken on WSL (buntu okay) #10269 - Compilation error for windows target #11437 Tree-SHA512: 7c937e37ed7120ae5dcf61aba50e5228a7ed6f729647c724b8f48e7cbbd81366c1a83a818618766a8fe0418425e05ba2eba2b14f2616621c58606585444f45fc
2 parents 2adbddb + 7383d77 commit 7fbf3c6

File tree

1 file changed

+57
-17
lines changed

1 file changed

+57
-17
lines changed

doc/build-windows.md

Lines changed: 57 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,14 @@ WINDOWS BUILD NOTES
44
Below are some notes on how to build Bitcoin Core for Windows.
55

66
Most developers use cross-compilation from Ubuntu to build executables for
7-
Windows. Cross-compilation is also used to build the release binaries.
7+
Windows. This is also used to build the release binaries.
88

9-
Currently only building on Ubuntu Trusty 14.04 or Ubuntu Zesty 17.04 or later is supported.
10-
Building on Ubuntu Xenial 16.04 is known to be broken, see extensive discussion in issue [8732](https://github.com/bitcoin/bitcoin/issues/8732).
11-
While it may be possible to do so with work arounds, it's potentially dangerous and not recommended.
9+
Building on Ubuntu Trusty 14.04 is recommended.
10+
At the time of writing the Windows Subsystem for Linux installs Ubuntu Xenial 16.04. The default cross
11+
compiler package for Ubuntu Xenial does not produce working executables for some of the bitcoin applications.
12+
It is possible to build on Ubuntu Xenial by installing the cross compiler packages from
13+
Ubuntu Zesty, see the steps below.
14+
Building on Ubuntu Zesty 17.04 up to 17.10 has been verified to work.
1215

1316
While there are potentially a number of ways to build on Windows (for example using msys / mingw-w64),
1417
using the Windows Subsystem For Linux is the most straightforward. If you are building with
@@ -19,7 +22,7 @@ Compiling with Windows Subsystem For Linux
1922
-------------------------------------------
2023

2124
With Windows 10, Microsoft has released a new feature named the [Windows
22-
Subsystem for Linux](https://msdn.microsoft.com/commandline/wsl/about). This
25+
Subsystem for Linux (WSL)](https://msdn.microsoft.com/commandline/wsl/about). This
2326
feature allows you to run a bash shell directly on Windows in an Ubuntu-based
2427
environment. Within this environment you can cross compile for Windows without
2528
the need for a separate Linux VM or server.
@@ -28,6 +31,10 @@ This feature is not supported in versions of Windows prior to Windows 10 or on
2831
Windows Server SKUs. In addition, it is available [only for 64-bit versions of
2932
Windows](https://msdn.microsoft.com/en-us/commandline/wsl/install_guide).
3033

34+
For Windows 10 systems with the Fall Creators Update applied (version >= 16215.0) use the Windows Store
35+
to install Ubuntu. Search for "Linux" in the Windows Store and install the free "Ubuntu" application.
36+
Full instructions are available on the above link.
37+
3138
To get the bash shell, you must first activate the feature in Windows.
3239

3340
1. Turn on Developer Mode
@@ -57,28 +64,40 @@ installing the toolchain will be different.
5764

5865
First, install the general dependencies:
5966

60-
sudo apt-get install build-essential libtool autotools-dev automake pkg-config bsdmainutils curl
67+
sudo apt install build-essential libtool autotools-dev automake pkg-config bsdmainutils curl git
6168

6269
A host toolchain (`build-essential`) is necessary because some dependency
6370
packages (such as `protobuf`) need to build host utilities that are used in the
6471
build process.
6572

6673
See also: [dependencies.md](dependencies.md).
6774

68-
If you're building on Ubuntu 17.04 or later, run these two commands, selecting the 'posix' variant for both,
69-
to work around issues with mingw-w64. See issue [8732](https://github.com/bitcoin/bitcoin/issues/8732) for more information.
70-
```
71-
sudo update-alternatives --config x86_64-w64-mingw32-g++
72-
sudo update-alternatives --config x86_64-w64-mingw32-gcc
73-
```
74-
7575
## Building for 64-bit Windows
7676

77-
To build executables for Windows 64-bit, install the following dependencies:
77+
The first step is to install the mingw-w64 cross-compilation tool chain. Due to different Ubuntu
78+
packages for each distribution and problems with the Xenial packages the steps for each are different.
7879

79-
sudo apt-get install g++-mingw-w64-x86-64 mingw-w64-x86-64-dev
80+
Common steps to install mingw32 cross compiler tool chain:
8081

81-
Then build using:
82+
sudo apt install g++-mingw-w64-x86-64
83+
84+
Ubuntu Trusty 14.04:
85+
86+
No further steps required
87+
88+
Ubuntu Xenial 16.04 and Windows Subsystem for Linux <sup>[1](#footnote1),[2](#footnote2)</sup>:
89+
90+
sudo apt install software-properties-common
91+
sudo add-apt-repository "deb http://archive.ubuntu.com/ubuntu zesty universe"
92+
sudo apt update
93+
sudo apt upgrade
94+
sudo update-alternatives --config x86_64-w64-mingw32-g++ # Set the default mingw32 g++ compiler option to posix.
95+
96+
Ubuntu Zesty 17.04 <sup>[2](#footnote2)</sup>:
97+
98+
sudo update-alternatives --config x86_64-w64-mingw32-g++ # Set the default mingw32 g++ compiler option to posix.
99+
100+
Once the tool chain is installed the build steps are common:
82101

83102
PATH=$(echo "$PATH" | sed -e 's/:\/mnt.*//g') # strip out problematic Windows %PATH% imported var
84103
cd depends
@@ -92,7 +111,11 @@ Then build using:
92111

93112
To build executables for Windows 32-bit, install the following dependencies:
94113

95-
sudo apt-get install g++-mingw-w64-i686 mingw-w64-i686-dev
114+
sudo apt install g++-mingw-w64-i686 mingw-w64-i686-dev
115+
116+
For Ubuntu Xenial 16.04, Ubuntu Zesty 17.04 and Windows Subsystem for Linux <sup>[2](#footnote2)</sup>:
117+
118+
sudo update-alternatives --config i686-w64-mingw32-g++ # Set the default mingw32 g++ compiler option to posix.
96119

97120
Then build using:
98121

@@ -117,3 +140,20 @@ as they appear in the release `.zip` archive. This can be done in the following
117140
way. This will install to `c:\workspace\bitcoin`, for example:
118141

119142
make install DESTDIR=/mnt/c/workspace/bitcoin
143+
144+
Footnotes
145+
---------
146+
147+
<a name="footnote1">1</a>: There is currently a bug in the 64 bit mingw-w64 cross compiler packaged for WSL/Ubuntu Xenial 16.04 that
148+
causes two of the bitcoin executables to crash shortly after start up. The bug is related to the
149+
-fstack-protector-all g++ compiler flag which is used to mitigate buffer overflows.
150+
Installing the mingw-w64 packages from the Ubuntu 17 distribution solves the issue, however, this is not
151+
an officially supported approach and it's only recommended if you are prepared to reinstall WSL/Ubutntu should
152+
something break.
153+
154+
<a name="footnote2">2</a>: Starting from Ubuntu Xenial 16.04 both the 32 and 64 bit mingw-w64 packages install two different
155+
compiler options to allow a choice between either posix or win32 threads. The default option is win32 threads which is the more
156+
efficient since it will result in binary code that links directly with the Windows kernel32.lib. Unfortunately, the headers
157+
required to support win32 threads conflict with some of the classes in the C++11 standard library in particular std::mutex.
158+
It's not possible to build the bitcoin code using the win32 version of the mingw-w64 cross compilers (at least not without
159+
modifying headers in the bitcoin source code).

0 commit comments

Comments
 (0)