@@ -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.
@@ -57,28 +60,40 @@ installing the toolchain will be different.
57
60
58
61
First, install the general dependencies:
59
62
60
- sudo apt-get install build-essential libtool autotools-dev automake pkg-config bsdmainutils curl
63
+ sudo apt install build-essential libtool autotools-dev automake pkg-config bsdmainutils curl git
61
64
62
65
A host toolchain (` build-essential ` ) is necessary because some dependency
63
66
packages (such as ` protobuf ` ) need to build host utilities that are used in the
64
67
build process.
65
68
66
69
See also: [ dependencies.md] ( dependencies.md ) .
67
70
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
71
## Building for 64-bit Windows
76
72
77
- To build executables for Windows 64-bit, install the following dependencies:
73
+ The first step is to install the mingw-w64 cross-compilation tool chain. Due to different Ubuntu
74
+ packages for each distribution and problems with the Xenial packages the steps for each are different.
78
75
79
- sudo apt-get install g++-mingw-w64-x86-64 mingw-w64-x86-64-dev
76
+ Common steps to install mingw32 cross compiler tool chain:
80
77
81
- Then build using:
78
+ sudo apt install g++-mingw-w64-x86-64
79
+
80
+ Ubuntu Trusty 14.04:
81
+
82
+ No further steps required
83
+
84
+ Ubuntu Xenial 16.04 and Windows Subsystem for Linux <sup >[ 1] ( #footnote1 ) ,[ 2] ( #footnote2 ) </sup >:
85
+
86
+ sudo apt install software-properties-common
87
+ sudo add-apt-repository "deb http://archive.ubuntu.com/ubuntu zesty universe"
88
+ sudo apt update
89
+ sudo apt upgrade
90
+ sudo update-alternatives --config x86_64-w64-mingw32-g++ # Set the default mingw32 g++ compiler option to posix.
91
+
92
+ Ubuntu Zesty 17.04 <sup >[ 2] ( #footnote2 ) </sup >:
93
+
94
+ sudo update-alternatives --config x86_64-w64-mingw32-g++ # Set the default mingw32 g++ compiler option to posix.
95
+
96
+ Once the tool chain is installed the build steps are common:
82
97
83
98
PATH=$(echo "$PATH" | sed -e 's/:\/mnt.*//g') # strip out problematic Windows %PATH% imported var
84
99
cd depends
@@ -92,7 +107,11 @@ Then build using:
92
107
93
108
To build executables for Windows 32-bit, install the following dependencies:
94
109
95
- sudo apt-get install g++-mingw-w64-i686 mingw-w64-i686-dev
110
+ sudo apt install g++-mingw-w64-i686 mingw-w64-i686-dev
111
+
112
+ For Ubuntu Xenial 16.04, Ubuntu Zesty 17.04 and Windows Subsystem for Linux <sup >[ 2] ( #footnote2 ) </sup >:
113
+
114
+ sudo update-alternatives --config i686-w64-mingw32-g++ # Set the default mingw32 g++ compiler option to posix.
96
115
97
116
Then build using:
98
117
@@ -117,3 +136,20 @@ as they appear in the release `.zip` archive. This can be done in the following
117
136
way. This will install to ` c:\workspace\bitcoin ` , for example:
118
137
119
138
make install DESTDIR=/mnt/c/workspace/bitcoin
139
+
140
+ Footnotes
141
+ ---------
142
+
143
+ <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
144
+ causes two of the bitcoin executables to crash shortly after start up. The bug is related to the
145
+ -fstack-protector-all g++ compiler flag which is used to mitigate buffer overflows.
146
+ Installing the mingw-w64 packages from the Ubuntu 17 distribution solves the issue, however, this is not
147
+ an officially supported approach and it's only recommended if you are prepared to reinstall WSL/Ubutntu should
148
+ something break.
149
+
150
+ <a name =" footnote2 " >2</a >: Starting from Ubuntu Xenial 16.04 both the 32 and 64 bit mingw-w64 packages install two different
151
+ compiler options to allow a choice between either posix or win32 threads. The default option is win32 threads which is the more
152
+ efficient since it will result in binary code that links directly with the Windows kernel32.lib. Unfortunately, the headers
153
+ required to support win32 threads conflict with some of the classes in the C++11 standard library in particular std::mutex.
154
+ It's not possible to build the bitcoin code using the win32 version of the mingw-w64 cross compilers (at least not without
155
+ modifying headers in the bitcoin source code).
0 commit comments