@@ -4,11 +4,14 @@ WINDOWS BUILD NOTES
4
4
Below are some notes on how to build Bitcoin Core for Windows.
5
5
6
6
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.
8
8
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.
12
15
13
16
While there are potentially a number of ways to build on Windows (for example using msys / mingw-w64),
14
17
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
19
22
-------------------------------------------
20
23
21
24
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
23
26
feature allows you to run a bash shell directly on Windows in an Ubuntu-based
24
27
environment. Within this environment you can cross compile for Windows without
25
28
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
28
31
Windows Server SKUs. In addition, it is available [ only for 64-bit versions of
29
32
Windows] ( https://msdn.microsoft.com/en-us/commandline/wsl/install_guide ) .
30
33
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
+
31
38
To get the bash shell, you must first activate the feature in Windows.
32
39
33
40
1 . Turn on Developer Mode
@@ -57,28 +64,40 @@ installing the toolchain will be different.
57
64
58
65
First, install the general dependencies:
59
66
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
61
68
62
69
A host toolchain (` build-essential ` ) is necessary because some dependency
63
70
packages (such as ` protobuf ` ) need to build host utilities that are used in the
64
71
build process.
65
72
66
73
See also: [ dependencies.md] ( dependencies.md ) .
67
74
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
-
75
75
## Building for 64-bit Windows
76
76
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.
78
79
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:
80
81
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:
82
101
83
102
PATH=$(echo "$PATH" | sed -e 's/:\/mnt.*//g') # strip out problematic Windows %PATH% imported var
84
103
cd depends
@@ -92,7 +111,11 @@ Then build using:
92
111
93
112
To build executables for Windows 32-bit, install the following dependencies:
94
113
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.
96
119
97
120
Then build using:
98
121
@@ -117,3 +140,20 @@ as they appear in the release `.zip` archive. This can be done in the following
117
140
way. This will install to ` c:\workspace\bitcoin ` , for example:
118
141
119
142
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